parsing wsdl with schema, but xsd namespace not declared in top node

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@595 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2008-10-17 20:31:55 +00:00
parent 8a190b28da
commit 8c09b81cfd
7 changed files with 189 additions and 11 deletions

View File

@ -0,0 +1,50 @@
<?xml version="1.0"?>
<definitions name="wst_test"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="urn:wst-test"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="urn:wst-test">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:wst-test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:complexType name="TClassSampleType">
<xsd:sequence>
<xsd:element name="intField" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</types>
<message name="test_proc">
<part name="AConstParam" type="tns:TClassSampleType"/>
</message>
<message name="test_procResponse">
</message>
<portType name="TestService">
<operation name="test_proc">
<input message="tns:test_proc"/>
<output message="tns:test_procResponse"/>
</operation>
</portType>
<binding name="TestServiceBinding" type="tns:TestService">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="test_proc">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="library1"/>
</input>
<output>
<soap:body use="literal" namespace="library1"/>
</output>
</operation>
</binding>
<service name="TestService">
<port name="TestServicePort" binding="tns:TestServiceBinding">
<soap:address location=""/>
</port>
</service>
</definitions>

View File

@ -0,0 +1,51 @@
<?xml version="1.0"?>
<definitions name="wst_test"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="urn:wst-test"
xmlns:other="urn:wst-other"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="urn:wst-test">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:wst-other" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:complexType name="TClassSampleType">
<xsd:sequence>
<xsd:element name="intField" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</types>
<message name="test_proc">
<part name="AConstParam" type="other:TClassSampleType"/>
</message>
<message name="test_procResponse">
</message>
<portType name="TestService">
<operation name="test_proc">
<input message="tns:test_proc"/>
<output message="tns:test_procResponse"/>
</operation>
</portType>
<binding name="TestServiceBinding" type="tns:TestService">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="test_proc">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="library1"/>
</input>
<output>
<soap:body use="literal" namespace="library1"/>
</output>
</operation>
</binding>
<service name="TestService">
<port name="TestServicePort" binding="tns:TestServiceBinding">
<soap:address location=""/>
</port>
</service>
</definitions>

View File

@ -157,6 +157,8 @@ type
procedure signature_last();
procedure signature_result();
procedure signature_return();
procedure xsd_not_declared_at_top_node();
procedure xsd_not_declared_at_top_node_2();
end;
implementation
@ -1573,7 +1575,7 @@ begin
Result := ParseDoc(x_complexType_class_properties_extended_metadata);
end;
function TTest_XsdParser.LoadComplexType_Class_properties_extended_metadata2: TwstPasTreeContainer;
function TTest_XsdParser.LoadComplexType_Class_properties_extended_metadata2(): TwstPasTreeContainer;
begin
Result := ParseDoc(x_complexType_class_properties_extended_metadata + '_2');
end;
@ -1926,6 +1928,16 @@ begin
end;
end;
procedure TTest_WsdlParser.xsd_not_declared_at_top_node();
begin
ParseDoc('xsd_not_declared_at_top_node').Free();
end;
procedure TTest_WsdlParser.xsd_not_declared_at_top_node_2();
begin
ParseDoc('xsd_not_declared_at_top_node_2').Free();
end;
function TTest_WsdlParser.LoadComplexType_Class_default_values() : TwstPasTreeContainer;
begin
Result := ParseDoc(x_complexType_class_default);
@ -1936,7 +1948,7 @@ begin
Result := ParseDoc(x_complexType_class_properties_extended_metadata);
end;
function TTest_WsdlParser.LoadComplexType_Class_properties_extended_metadata2: TwstPasTreeContainer;
function TTest_WsdlParser.LoadComplexType_Class_properties_extended_metadata2(): TwstPasTreeContainer;
begin
Result := ParseDoc(x_complexType_class_properties_extended_metadata + '_2');
end;

View File

@ -1,12 +1,12 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="/"/>
<PathDelim Value="\"/>
<Version Value="6"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<IconPath Value=".\"/>
<TargetFileExt Value=".exe"/>
</General>
<VersionInfo>
@ -14,13 +14,14 @@
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="$(TestDir)\publishedproject\"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="3">
@ -96,12 +97,12 @@
<UnitName Value="test_rtti_filter"/>
</Unit11>
<Unit12>
<Filename Value="../../wst_rtti_filter/rtti_filters.pas"/>
<Filename Value="..\..\wst_rtti_filter\rtti_filters.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="rtti_filters"/>
</Unit12>
<Unit13>
<Filename Value="../../wst_rtti_filter/wst_cursors.pas"/>
<Filename Value="..\..\wst_rtti_filter\wst_cursors.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="wst_cursors"/>
</Unit13>
@ -129,9 +130,10 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<PathDelim Value="\"/>
<SearchPaths>
<IncludeFiles Value="../../"/>
<OtherUnitFiles Value="../../;../../ws_helper/;../../wst_rtti_filter/;../../fcl-json/src/"/>
<IncludeFiles Value="..\..\"/>
<OtherUnitFiles Value="..\..\;..\..\ws_helper\;..\..\wst_rtti_filter\;..\..\fcl-json\src\"/>
<UnitOutputDirectory Value="obj"/>
</SearchPaths>
<Parsing>

View File

@ -33,6 +33,20 @@ type
const
sNEW_LINE = sLineBreak;
type
{ TQualifiedNameObjectFilter }
TQualifiedNameObjectFilter = class(TInterfacedObject,IObjectFilter)
private
FNameSpace : string;
FName : string;
protected
function Evaluate(const AObject : TObject) : Boolean;
public
constructor Create(const AName,ANameSpace : string);
end;
function IsStrEmpty(Const AStr : String):Boolean;
function ExtractIdentifier(const AValue : string) : string ;
{$IFDEF WST_HANDLE_DOC}
@ -430,4 +444,45 @@ begin
end;
{ TQualifiedNameObjectFilter }
function TQualifiedNameObjectFilter.Evaluate(const AObject: TObject): Boolean;
var
locObj : TDOMNodeRttiExposer;
startPos, i : PtrInt;
shortNameSpace : string;
locContinue : Boolean;
tmpNode : TDOMNode;
begin
Result := False;
if ( AObject <> nil ) then begin
locObj := TDOMNodeRttiExposer(AObject);
i := Length(FName);
startPos := ( Length(locObj.NodeName) - i + 1 );
if ( startPos > 0 ) and ( FName = Copy(locObj.NodeName,startPos,i) ) then begin
if ( startPos = 1 ) then begin
shortNameSpace := 'xmlns';
locContinue := True;
end else begin
locContinue := ( startPos > 2 ) and ( locObj.NodeName[startPos-1] = ':' );
if locContinue then
shortNameSpace := 'xmlns:' + Copy(locObj.NodeName,1,( startPos - 2 ));
end;
if locContinue then begin
if ( locObj.InnerObject.Attributes <> nil ) then begin
tmpNode := locObj.InnerObject.Attributes.GetNamedItem(shortNameSpace);
if ( tmpNode <> nil ) and ( tmpNode.NodeValue = FNameSpace ) then
Result := True;
end;
end;
end;
end;
end;
constructor TQualifiedNameObjectFilter.Create(const AName, ANameSpace: string);
begin
FName := AName;
FNameSpace := ANameSpace;;
end;
end.

View File

@ -19,7 +19,7 @@ uses
{$IFNDEF FPC}xmldom, wst_delphi_xml{$ELSE}DOM, wst_fpc_xml{$ENDIF},
cursor_intf, rtti_filters,
pastree, pascal_parser_intf, logger_intf,
xsd_parser;
xsd_parser, wst_types;
type

View File

@ -1229,8 +1229,16 @@ begin
FSchemaCursor.Reset();
FSchemaCursor := CreateCursorOn(
FSchemaCursor,
ParseFilter(CreateQualifiedNameFilterStr(s_schema,FXSShortNames),TDOMNodeRttiExposer)
TAggregatedFilter.Create(
ParseFilter(CreateQualifiedNameFilterStr(s_schema,FXSShortNames),TDOMNodeRttiExposer),
TQualifiedNameObjectFilter.Create(s_schema,s_xs),
fcOr
)
);
{ FSchemaCursor := CreateCursorOn(
FSchemaCursor,
ParseFilter(CreateQualifiedNameFilterStr(s_schema,FXSShortNames),TDOMNodeRttiExposer)
);}
FSchemaCursor.Reset();
if FSchemaCursor.MoveNext() then begin
FSchemaCursor.Reset();