ws_helper : nested type definition parsing

Example :
	        <xs:element name="NestedType">
	                <xs:complexType>
	                        <xs:sequence>
	                                <xs:element name="Property_1" type="xs:string"/>
	                                <xs:element name="Property_2" minOccurs="0" maxOccurs="unbounded">
      		                              <xs:complexType>
      	                                          <xs:sequence>
      	                                                 <xs:element name="Name" type="xs:string"/>
      	                                                 <xs:element name="Value" type="xs:string"/>
      	                                          </xs:sequence>
      	                                </xs:complexType>
	                                </xs:element>
	                        </xs:sequence>
	                </xs:complexType>
	        </xs:element>

ws_helper : Soap Binding Style are now recorded in the metadata registration subroutine generated by ws_helper


git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@144 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2007-04-12 00:48:00 +00:00
parent 98a3f13377
commit bbeed9acfd
9 changed files with 652 additions and 364 deletions

View File

@ -35,6 +35,8 @@ type
{ standart data types defines }
anyURI = type string;
token = type string;
nonNegativeInteger = type LongWord;
positiveInteger = type nonNegativeInteger;
float = Single;
TScopeType = Integer;
@ -1121,6 +1123,9 @@ begin
r := GetTypeRegistry();
r.Register(sXSD_NS,TypeInfo(Integer),'int').AddPascalSynonym('Integer');
r.Register(sXSD_NS,TypeInfo(LongWord),'unsignedInt');
r.Register(sXSD_NS,TypeInfo(positiveInteger),'positiveInteger');
r.Register(sXSD_NS,TypeInfo(nonNegativeInteger),'nonNegativeInteger');
r.Register(sXSD_NS,TypeInfo(string),'string').AddPascalSynonym('string');
r.Register(sXSD_NS,TypeInfo(AnsiString),'ansistring').AddPascalSynonym('ansistring');

View File

@ -7,7 +7,7 @@
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
<ActiveEditorIndexAtStart Value="3"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<PublishOptions>
<Version Value="2"/>
@ -33,7 +33,7 @@
<UnitName Value="test_ebay_gui"/>
<CursorPos X="5" Y="8"/>
<TopLine Value="1"/>
<UsageCount Value="127"/>
<UsageCount Value="128"/>
</Unit0>
<Unit1>
<Filename Value="umain.pas"/>
@ -41,10 +41,10 @@
<IsPartOfProject Value="True"/>
<ResourceFilename Value="umain.lrs"/>
<UnitName Value="umain"/>
<CursorPos X="40" Y="9"/>
<TopLine Value="4"/>
<CursorPos X="36" Y="69"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="127"/>
<UsageCount Value="128"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
@ -53,32 +53,34 @@
<UnitName Value="synapse_http_protocol"/>
<CursorPos X="1" Y="162"/>
<TopLine Value="149"/>
<UsageCount Value="127"/>
<UsageCount Value="128"/>
</Unit2>
<Unit3>
<Filename Value="..\..\base_service_intf.pas"/>
<UnitName Value="base_service_intf"/>
<CursorPos X="13" Y="3058"/>
<TopLine Value="3056"/>
<EditorIndex Value="7"/>
<UsageCount Value="63"/>
<CursorPos X="68" Y="109"/>
<TopLine Value="21"/>
<EditorIndex Value="9"/>
<UsageCount Value="64"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\..\service_intf.pas"/>
<UnitName Value="service_intf"/>
<CursorPos X="1" Y="253"/>
<TopLine Value="239"/>
<EditorIndex Value="2"/>
<UsageCount Value="28"/>
<CursorPos X="32" Y="78"/>
<TopLine Value="67"/>
<EditorIndex Value="3"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="..\..\soap_formatter.pas"/>
<UnitName Value="soap_formatter"/>
<CursorPos X="1" Y="146"/>
<TopLine Value="132"/>
<UsageCount Value="20"/>
<CursorPos X="3" Y="93"/>
<TopLine Value="87"/>
<EditorIndex Value="1"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="..\..\imp_utils.pas"/>
@ -90,10 +92,10 @@
<Unit7>
<Filename Value="..\..\base_soap_formatter.pas"/>
<UnitName Value="base_soap_formatter"/>
<CursorPos X="1" Y="1625"/>
<TopLine Value="1611"/>
<EditorIndex Value="4"/>
<UsageCount Value="56"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="219"/>
<EditorIndex Value="6"/>
<UsageCount Value="57"/>
<Bookmarks Count="2">
<Item0 X="14" Y="670" ID="1"/>
<Item1 X="1" Y="437" ID="2"/>
@ -111,10 +113,10 @@
<Filename Value="ebay.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ebay"/>
<CursorPos X="49" Y="126"/>
<TopLine Value="124"/>
<EditorIndex Value="1"/>
<UsageCount Value="111"/>
<CursorPos X="3" Y="237"/>
<TopLine Value="226"/>
<EditorIndex Value="2"/>
<UsageCount Value="112"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
@ -129,8 +131,8 @@
<UnitName Value="metadata_repository"/>
<CursorPos X="3" Y="112"/>
<TopLine Value="9"/>
<EditorIndex Value="5"/>
<UsageCount Value="19"/>
<EditorIndex Value="7"/>
<UsageCount Value="20"/>
<Bookmarks Count="1">
<Item0 X="1" Y="91" ID="3"/>
</Bookmarks>
@ -140,10 +142,10 @@
<Filename Value="ebay_proxy.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ebay_proxy"/>
<CursorPos X="1" Y="75"/>
<TopLine Value="61"/>
<EditorIndex Value="6"/>
<UsageCount Value="111"/>
<CursorPos X="44" Y="16"/>
<TopLine Value="5"/>
<EditorIndex Value="8"/>
<UsageCount Value="112"/>
<Loaded Value="True"/>
</Unit12>
<Unit13>
@ -244,26 +246,28 @@
</Unit27>
<Unit28>
<Filename Value="..\..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\inc\objpash.inc"/>
<CursorPos X="8" Y="116"/>
<TopLine Value="102"/>
<UsageCount Value="6"/>
<CursorPos X="50" Y="190"/>
<TopLine Value="179"/>
<EditorIndex Value="4"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit28>
<Unit29>
<Filename Value="..\..\binary_streamer.pas"/>
<UnitName Value="binary_streamer"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="55"/>
<EditorIndex Value="8"/>
<UsageCount Value="31"/>
<EditorIndex Value="10"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit29>
<Unit30>
<Filename Value="..\files\eBayWSDL.pas"/>
<UnitName Value="eBayWSDL"/>
<CursorPos X="48" Y="10961"/>
<TopLine Value="10947"/>
<EditorIndex Value="3"/>
<UsageCount Value="18"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="19"/>
<Loaded Value="True"/>
</Unit30>
<Unit31>
@ -316,31 +320,47 @@
<UsageCount Value="10"/>
</Unit37>
</Units>
<JumpHistory Count="6" HistoryIndex="5">
<JumpHistory Count="10" HistoryIndex="9">
<Position1>
<Filename Value="..\files\eBayWSDL.pas"/>
<Caret Line="33919" Column="45" TopLine="33905"/>
<Filename Value="umain.pas"/>
<Caret Line="77" Column="14" TopLine="64"/>
</Position1>
<Position2>
<Filename Value="..\files\eBayWSDL.pas"/>
<Caret Line="32893" Column="23" TopLine="32867"/>
<Filename Value="umain.pas"/>
<Caret Line="54" Column="20" TopLine="43"/>
</Position2>
<Position3>
<Filename Value="..\files\eBayWSDL.pas"/>
<Caret Line="12" Column="53" TopLine="1"/>
<Filename Value="umain.pas"/>
<Caret Line="45" Column="70" TopLine="39"/>
</Position3>
<Position4>
<Filename Value="..\files\eBayWSDL.pas"/>
<Caret Line="32726" Column="1" TopLine="32699"/>
<Filename Value="..\..\service_intf.pas"/>
<Caret Line="245" Column="15" TopLine="239"/>
</Position4>
<Position5>
<Filename Value="..\files\eBayWSDL.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="..\..\service_intf.pas"/>
<Caret Line="23" Column="12" TopLine="21"/>
</Position5>
<Position6>
<Filename Value="..\files\eBayWSDL.pas"/>
<Caret Line="503" Column="3" TopLine="489"/>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position6>
<Position7>
<Filename Value="umain.pas"/>
<Caret Line="45" Column="27" TopLine="39"/>
</Position7>
<Position8>
<Filename Value="umain.pas"/>
<Caret Line="69" Column="36" TopLine="56"/>
</Position8>
<Position9>
<Filename Value="ebay_proxy.pas"/>
<Caret Line="16" Column="44" TopLine="5"/>
</Position9>
<Position10>
<Filename Value="..\..\service_intf.pas"/>
<Caret Line="78" Column="32" TopLine="67"/>
</Position10>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -80,12 +80,13 @@
<Filename Value="..\..\base_service_intf.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="base_service_intf"/>
<CursorPos X="3" Y="119"/>
<TopLine Value="132"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="28"/>
<EditorIndex Value="0"/>
<UsageCount Value="200"/>
<Bookmarks Count="1">
<Item0 X="5" Y="1175" ID="1"/>
<Bookmarks Count="2">
<Item0 X="33" Y="1126" ID="0"/>
<Item1 X="5" Y="1180" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit5>
@ -330,11 +331,39 @@
<UsageCount Value="8"/>
</Unit37>
</Units>
<JumpHistory Count="1" HistoryIndex="0">
<JumpHistory Count="8" HistoryIndex="7">
<Position1>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="587" Column="29" TopLine="571"/>
<Caret Line="119" Column="3" TopLine="132"/>
</Position1>
<Position2>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="825" Column="90" TopLine="817"/>
</Position2>
<Position3>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="3944" Column="90" TopLine="3937"/>
</Position3>
<Position4>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position4>
<Position5>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="1125" Column="66" TopLine="1112"/>
</Position5>
<Position6>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="36" Column="9" TopLine="25"/>
</Position6>
<Position7>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="1129" Column="37" TopLine="1115"/>
</Position7>
<Position8>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="1127" Column="72" TopLine="1113"/>
</Position8>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -1813,6 +1813,17 @@ procedure TInftGenerator.GenerateCustomMetadatas();
DecIndent();
Indent();WriteLn(');');
end;
if ( AIntf.BindingStyle = bsRPC ) then begin
Indent();WriteLn('mm.SetServiceCustomData(');
IncIndent();
Indent(); WriteLn('%s,',[sUNIT_NAME]);
Indent(); WriteLn('%s,',[QuotedStr(AIntf.Name)]);
Indent(); WriteLn('%s,',[QuotedStr('SoapStyle')]);
Indent(); WriteLn('%s' ,[QuotedStr('rpc')]);
DecIndent();
Indent();WriteLn(');');
end;
for k := 0 to Pred(AIntf.MethodCount) do begin
WriteOperationDatas(AIntf,AIntf.Method[k]);

View File

@ -330,6 +330,8 @@ Type
property Properties : TStrings read FProperties;
End;
TBindingStyle = ( bsDocument, bsRPC, bsUnknown );
{ TInterfaceDefinition }
TInterfaceDefinition = class(TAbstractSymbolDefinition)
@ -338,6 +340,7 @@ Type
FMethodList : TObjectList;
private
FAddress: string;
FBindingStyle: TBindingStyle;
function GetMethod(Index: Integer): TMethodDefinition;
function GetMethodCount: Integer;
protected
@ -359,6 +362,7 @@ Type
Property Method[Index:Integer] : TMethodDefinition Read GetMethod;
property InterfaceGUID : string read FInterfaceGUID write FInterfaceGUID;
property Address : string read FAddress write FAddress;
property BindingStyle : TBindingStyle read FBindingStyle write FBindingStyle;
End;
{ TSymbolTable }
@ -442,9 +446,11 @@ const LANGAGE_TOKEN : array[0..107] of string = (
'THEN', 'TO', 'TRY', 'TYPE', 'UNIT', 'UNTIL', 'USES',
'VAR', 'VARARGS', 'VARIANT', 'VIRTUAL', 'WHILE', 'WIDECHAR', 'WITH', 'WORD', 'WRITE', 'XOR'
);
const WST_RESERVED_TOKEN : array[0..1] of string = ( 'Item', 'Item' );
function IsReservedKeyWord(const AValue : string):Boolean ;
begin
Result := AnsiMatchText(AValue,LANGAGE_TOKEN);
Result := AnsiMatchText(AValue,LANGAGE_TOKEN) or
AnsiMatchText(AValue,WST_RESERVED_TOKEN);
end;
{ TAbstractSymbolDefinition }
@ -791,7 +797,7 @@ begin
then
locNeedFix := True
else
raise ESymbolException.CreateFmt('Duplicated symbol name : %s',[ASym.Name]);
raise ESymbolException.CreateFmt('Duplicated symbol name %s : ( %s/%s ), ( %s/%s )',[ASym.Name,Item[i].ClassName,Item[i].ExternalName,ASym.ClassName,ASym.ExternalName]);
end;
NotifyChange(Self,ASym,stcAdding);
Result := FList.Add(ASym);
@ -1229,7 +1235,11 @@ begin
Result.Add(locTyp);
locTyp := TTypeAliasDefinition.Create('float',Result.ByName('Single') as TTypeDefinition);
Result.Add(locTyp);
locTyp := TTypeAliasDefinition.Create('nonNegativeInteger',Result.ByName('LongWord') as TTypeDefinition);
Result.Add(locTyp);
locTyp := TTypeAliasDefinition.Create('positiveInteger',Result.ByName('nonNegativeInteger') as TTypeDefinition);
Result.Add(locTyp);
locTyp := TTypeAliasDefinition.Create('base64Binary',Result.ByName('string') as TTypeDefinition);
Result.Add(locTyp);

View File

@ -30,6 +30,7 @@ const
sNEW_LINE = {$ifndef Unix}#13#10{$else}#10{$endif};
function IsStrEmpty(Const AStr : String):Boolean;
function ExtractIdentifier(const AValue : string) : string ;
implementation
@ -38,5 +39,30 @@ begin
Result := ( Length(Trim(AStr)) = 0 );
end;
function ExtractIdentifier(const AValue : string) : string ;
var
i, c : Integer;
s : string;
begin
Result := '';
s := Trim(AValue);
c := Length(s);
if ( c > 0 ) then begin
if not ( s[1] in ['A'..'Z', 'a'..'z', '_'] ) then begin
Result := '_';
end;
for i := 1 to c do begin
if ( s[i] in ['A'..'Z', 'a'..'z', '0'..'9', '_'] ) then begin
Result := Result + s[i];
end else begin
if ( Length(Result) > 0 ) and ( Result[Length(Result)] <> '_' ) then begin
Result := Result + '_';
end;
end;
end;
end;
end;
end.

View File

@ -12,7 +12,7 @@
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<ActiveEditorIndexAtStart Value="0"/>
<ActiveEditorIndexAtStart Value="8"/>
</General>
<PublishOptions>
<Version Value="2"/>
@ -24,7 +24,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
<CommandLineParams Value="-u -i -p -b -a&quot;C:\Programmes\lazarus\wst\tests\files&quot; &quot;C:\Programmes\lazarus\wst\tests\files\MathService.wsdl&quot;"/>
<CommandLineParams Value="-u -i -p -b -a&quot;C:\Programmes\lazarus\wst\tests\files&quot; &quot;C:\Programmes\lazarus\wst\tests\files\free\AWSECommerceService.wsdl&quot;"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
@ -33,14 +33,14 @@
<PackageName Value="FCL"/>
</Item1>
</RequiredPackages>
<Units Count="49">
<Units Count="46">
<Unit0>
<Filename Value="ws_helper.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ws_helper"/>
<CursorPos X="9" Y="77"/>
<TopLine Value="195"/>
<EditorIndex Value="1"/>
<CursorPos X="1" Y="122"/>
<TopLine Value="1"/>
<EditorIndex Value="8"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit0>
@ -49,8 +49,8 @@
<IsPartOfProject Value="True"/>
<UnitName Value="ws_parser"/>
<CursorPos X="1" Y="437"/>
<TopLine Value="423"/>
<EditorIndex Value="9"/>
<TopLine Value="417"/>
<EditorIndex Value="7"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit1>
@ -58,15 +58,14 @@
<Filename Value="generator.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="generator"/>
<CursorPos X="53" Y="1766"/>
<TopLine Value="1756"/>
<CursorPos X="50" Y="1823"/>
<TopLine Value="1798"/>
<EditorIndex Value="0"/>
<UsageCount Value="200"/>
<Bookmarks Count="4">
<Item0 X="43" Y="722" ID="0"/>
<Item1 X="69" Y="859" ID="1"/>
<Item2 X="17" Y="219" ID="2"/>
<Item3 X="23" Y="1820" ID="4"/>
<Bookmarks Count="3">
<Item0 X="69" Y="859" ID="1"/>
<Item1 X="17" Y="219" ID="2"/>
<Item2 X="23" Y="1831" ID="4"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit2>
@ -74,19 +73,22 @@
<Filename Value="parserdefs.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="parserdefs"/>
<CursorPos X="15" Y="312"/>
<TopLine Value="298"/>
<EditorIndex Value="7"/>
<CursorPos X="48" Y="365"/>
<TopLine Value="353"/>
<EditorIndex Value="5"/>
<UsageCount Value="200"/>
<Bookmarks Count="1">
<Item0 X="69" Y="1238" ID="0"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="parserutils.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="parserutils"/>
<CursorPos X="1" Y="39"/>
<TopLine Value="1"/>
<EditorIndex Value="8"/>
<CursorPos X="1" Y="40"/>
<TopLine Value="19"/>
<EditorIndex Value="6"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit4>
@ -94,7 +96,7 @@
<Filename Value="ws_helper.lpi"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="7"/>
<UsageCount Value="10"/>
<SyntaxHighlighter Value="None"/>
</Unit5>
<Unit6>
@ -102,42 +104,42 @@
<UnitName Value="Classes"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="7"/>
<UsageCount Value="10"/>
</Unit6>
<Unit7>
<Filename Value="usr\share\fpcsrc\rtl\objpas\strutils.pp"/>
<UnitName Value="strutils"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="7"/>
<UsageCount Value="10"/>
</Unit7>
<Unit8>
<Filename Value="usr\share\fpcsrc\rtl\unix\sysutils.pp"/>
<UnitName Value="sysutils"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="7"/>
<UsageCount Value="10"/>
</Unit8>
<Unit9>
<Filename Value="D:\Lazarus\others_package\indy\indy-10.2.0.1\lazarus\IdDsnCoreResourceStrings.pas"/>
<UnitName Value="IdDsnCoreResourceStrings"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="8"/>
<UsageCount Value="1"/>
</Unit9>
<Unit10>
<Filename Value="D:\Lazarus\others_package\indy\indy-10.2.0.1\lazarus\IdDsnPropEdBinding.pas"/>
<UnitName Value="IdDsnPropEdBinding"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="8"/>
<UsageCount Value="1"/>
</Unit10>
<Unit11>
<Filename Value="D:\Lazarus\ide\lazarus.pp"/>
<UnitName Value="Lazarus"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="8"/>
<UsageCount Value="1"/>
</Unit11>
<Unit12>
<Filename Value="source_utils.pas"/>
@ -148,266 +150,275 @@
<UsageCount Value="201"/>
</Unit12>
<Unit13>
<Filename Value="D:\lazarusClean\fpcsrc\rtl\inc\getopts.pp"/>
<UnitName Value="getopts"/>
<CursorPos X="16" Y="45"/>
<TopLine Value="33"/>
<UsageCount Value="3"/>
</Unit13>
<Unit14>
<Filename Value="D:\lazarusClean\fpcsrc\rtl\objpas\strutils.pp"/>
<UnitName Value="strutils"/>
<CursorPos X="23" Y="246"/>
<TopLine Value="246"/>
<UsageCount Value="2"/>
</Unit14>
<Unit15>
<UsageCount Value="5"/>
</Unit13>
<Unit14>
<Filename Value="D:\lazarusClean\fpcsrc\rtl\objpas\sysutils\sysstrh.inc"/>
<CursorPos X="10" Y="74"/>
<TopLine Value="70"/>
<UsageCount Value="2"/>
</Unit15>
<Unit16>
<UsageCount Value="5"/>
</Unit14>
<Unit15>
<Filename Value="D:\lazarusClean\fpcsrc\rtl\objpas\sysutils\sysstr.inc"/>
<CursorPos X="3" Y="185"/>
<TopLine Value="180"/>
<UsageCount Value="2"/>
</Unit16>
<Unit17>
<UsageCount Value="5"/>
</Unit15>
<Unit16>
<Filename Value="command_line_parser.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="command_line_parser"/>
<CursorPos X="38" Y="63"/>
<TopLine Value="43"/>
<EditorIndex Value="2"/>
<TopLine Value="42"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
</Unit16>
<Unit17>
<Filename Value="metadata_generator.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="metadata_generator"/>
<CursorPos X="3" Y="96"/>
<TopLine Value="69"/>
<EditorIndex Value="3"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit18>
<Unit19>
</Unit17>
<Unit18>
<Filename Value="..\binary_streamer.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="binary_streamer"/>
<CursorPos X="32" Y="344"/>
<TopLine Value="328"/>
<UsageCount Value="200"/>
</Unit19>
<Unit20>
<Filename Value="D:\Lazarus\fpcsrc\rtl\objpas\sysutils\finah.inc"/>
<CursorPos X="11" Y="27"/>
<TopLine Value="1"/>
<UsageCount Value="1"/>
</Unit20>
<Unit21>
<Filename Value="D:\Lazarus\fpcsrc\rtl\objpas\sysutils\fina.inc"/>
<CursorPos X="3" Y="26"/>
<TopLine Value="23"/>
<UsageCount Value="1"/>
</Unit21>
<Unit22>
</Unit18>
<Unit19>
<Filename Value="D:\Lazarus\fpcsrc\rtl\objpas\classes\classesh.inc"/>
<CursorPos X="17" Y="662"/>
<TopLine Value="652"/>
<UsageCount Value="8"/>
</Unit22>
<Unit23>
<Filename Value="D:\Lazarus\fpcsrc\rtl\objpas\sysutils\filutilh.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="54"/>
<UsageCount Value="1"/>
</Unit23>
<Unit24>
<Filename Value="D:\Lazarus\lcl\lresources.pp"/>
<UnitName Value="LResources"/>
<CursorPos X="15" Y="590"/>
<TopLine Value="586"/>
<UsageCount Value="4"/>
</Unit24>
<Unit25>
<Filename Value="D:\Lazarus\fpcsrc\rtl\win\sysutils.pp"/>
<UnitName Value="sysutils"/>
<CursorPos X="12" Y="33"/>
<TopLine Value="11"/>
<UsageCount Value="1"/>
</Unit25>
<Unit26>
<Filename Value="D:\Lazarus\fpcsrc\rtl\objpas\sysutils\sysutilh.inc"/>
<CursorPos X="11" Y="221"/>
<TopLine Value="194"/>
<UsageCount Value="1"/>
</Unit26>
<Unit27>
<Filename Value="D:\lazarusClean\fpcsrc\rtl\win32\classes.pp"/>
<UnitName Value="Classes"/>
<CursorPos X="1" Y="47"/>
<TopLine Value="25"/>
<UsageCount Value="1"/>
</Unit27>
<Unit28>
<Filename Value="D:\lazarusClean\fpcsrc\rtl\objpas\classes\classesh.inc"/>
<CursorPos X="30" Y="1183"/>
<TopLine Value="1171"/>
<UsageCount Value="3"/>
</Unit28>
<Unit29>
<Filename Value="D:\lazarusClean\fpcsrc\rtl\objpas\classes\parser.inc"/>
<CursorPos X="3" Y="303"/>
<TopLine Value="299"/>
<UsageCount Value="3"/>
</Unit29>
<Unit30>
</Unit19>
<Unit20>
<Filename Value="wst_resources_utils.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="wst_resources_utils"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="117"/>
</Unit30>
<Unit31>
<UsageCount Value="184"/>
</Unit20>
<Unit21>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\win32\classes.pp"/>
<UnitName Value="Classes"/>
<CursorPos X="1" Y="47"/>
<TopLine Value="20"/>
<UsageCount Value="8"/>
</Unit31>
<Unit32>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\win32\sysutils.pp"/>
<UnitName Value="sysutils"/>
<CursorPos X="15" Y="33"/>
<TopLine Value="1"/>
<UsageCount Value="5"/>
</Unit32>
<Unit33>
<TopLine Value="5"/>
<UsageCount Value="12"/>
</Unit21>
<Unit22>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\objpas\sysutils\sysutilh.inc"/>
<CursorPos X="13" Y="178"/>
<TopLine Value="163"/>
<UsageCount Value="10"/>
</Unit33>
<Unit34>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\objpas\sysutils\osutilsh.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="5"/>
</Unit34>
<Unit35>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\objpas\sysutils\finah.inc"/>
<CursorPos X="10" Y="30"/>
<TopLine Value="16"/>
<UsageCount Value="5"/>
</Unit35>
<Unit36>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\objpas\sysutils\fina.inc"/>
<CursorPos X="15" Y="102"/>
<TopLine Value="78"/>
<UsageCount Value="5"/>
</Unit36>
<Unit37>
<UsageCount Value="3"/>
</Unit22>
<Unit23>
<Filename Value="..\wsdl_to_pascal\wsdl2pas_imp.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="wsdl2pas_imp"/>
<CursorPos X="29" Y="1641"/>
<TopLine Value="1633"/>
<UsageCount Value="109"/>
</Unit37>
<Unit38>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\inc\fexpand.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="124"/>
<UsageCount Value="5"/>
</Unit38>
<Unit39>
<UsageCount Value="176"/>
</Unit23>
<Unit24>
<Filename Value="..\wst_rtti_filter\rtti_filters.pas"/>
<UnitName Value="rtti_filters"/>
<CursorPos X="1" Y="571"/>
<TopLine Value="557"/>
<UsageCount Value="10"/>
</Unit39>
<Unit40>
<CursorPos X="1" Y="209"/>
<TopLine Value="198"/>
<EditorIndex Value="2"/>
<UsageCount Value="44"/>
<Loaded Value="True"/>
</Unit24>
<Unit25>
<Filename Value="..\wst_rtti_filter\dom_cursors.pas"/>
<UnitName Value="dom_cursors"/>
<CursorPos X="3" Y="110"/>
<TopLine Value="108"/>
<EditorIndex Value="5"/>
<UsageCount Value="36"/>
<CursorPos X="1" Y="172"/>
<TopLine Value="161"/>
<EditorIndex Value="3"/>
<UsageCount Value="70"/>
<Loaded Value="True"/>
</Unit40>
<Unit41>
</Unit25>
<Unit26>
<Filename Value="..\wst_rtti_filter\cursor_intf.pas"/>
<UnitName Value="cursor_intf"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="6"/>
<UsageCount Value="38"/>
<CursorPos X="1" Y="98"/>
<TopLine Value="87"/>
<EditorIndex Value="4"/>
<UsageCount Value="72"/>
<Loaded Value="True"/>
</Unit41>
<Unit42>
</Unit26>
<Unit27>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\objpas\sysutils\sysstrh.inc"/>
<CursorPos X="41" Y="69"/>
<TopLine Value="67"/>
<UsageCount Value="6"/>
</Unit42>
<Unit43>
<CursorPos X="10" Y="100"/>
<TopLine Value="86"/>
<UsageCount Value="26"/>
</Unit27>
<Unit28>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\fcl\xml\dom.pp"/>
<UnitName Value="DOM"/>
<CursorPos X="14" Y="232"/>
<TopLine Value="215"/>
<UsageCount Value="9"/>
</Unit43>
<Unit44>
<CursorPos X="3" Y="1387"/>
<TopLine Value="1385"/>
<UsageCount Value="3"/>
</Unit28>
<Unit29>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\inc\objpash.inc"/>
<CursorPos X="26" Y="139"/>
<TopLine Value="125"/>
<UsageCount Value="8"/>
</Unit44>
<Unit45>
<UsageCount Value="1"/>
</Unit29>
<Unit30>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\inc\objpas.inc"/>
<CursorPos X="11" Y="360"/>
<TopLine Value="354"/>
<UsageCount Value="8"/>
</Unit45>
<Unit46>
<UsageCount Value="1"/>
</Unit30>
<Unit31>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\objpas\classes\classesh.inc"/>
<CursorPos X="14" Y="219"/>
<TopLine Value="183"/>
<UsageCount Value="9"/>
</Unit46>
<Unit47>
<CursorPos X="14" Y="151"/>
<TopLine Value="137"/>
<UsageCount Value="5"/>
</Unit31>
<Unit32>
<Filename Value="wsdl2pas_imp.pas"/>
<UnitName Value="wsdl2pas_imp"/>
<CursorPos X="3" Y="543"/>
<TopLine Value="447"/>
<EditorIndex Value="4"/>
<UsageCount Value="29"/>
<CursorPos X="16" Y="543"/>
<TopLine Value="532"/>
<EditorIndex Value="1"/>
<UsageCount Value="63"/>
<Bookmarks Count="1">
<Item0 X="21" Y="665" ID="3"/>
<Item0 X="21" Y="659" ID="3"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit47>
<Unit48>
</Unit32>
<Unit33>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\objpas\sysutils\sysutils.inc"/>
<CursorPos X="3" Y="567"/>
<TopLine Value="565"/>
<UsageCount Value="3"/>
</Unit33>
<Unit34>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\fcl\xml\xmlread.pp"/>
<UnitName Value="XMLRead"/>
<CursorPos X="3" Y="954"/>
<TopLine Value="928"/>
<UsageCount Value="3"/>
</Unit34>
<Unit35>
<Filename Value="..\..\..\..\lazarus211\fpc\2.1.1\source\rtl\win32\classes.pp"/>
<UnitName Value="Classes"/>
<CursorPos X="11" Y="43"/>
<TopLine Value="20"/>
<UsageCount Value="3"/>
</Unit35>
<Unit36>
<Filename Value="..\..\..\..\lazarus211\fpc\2.1.1\source\rtl\win\wininc\messages.inc"/>
<CursorPos X="6" Y="1219"/>
<TopLine Value="639"/>
<UsageCount Value="3"/>
</Unit36>
<Unit37>
<Filename Value="..\..\..\..\lazarus211\fpc\2.1.1\source\rtl\objpas\classes\classes.inc"/>
<CursorPos X="24" Y="20"/>
<TopLine Value="13"/>
<UsageCount Value="3"/>
</Unit37>
<Unit38>
<Filename Value="..\..\..\..\lazarus211\fpc\2.1.1\source\rtl\objpas\classes\classesh.inc"/>
<CursorPos X="26" Y="301"/>
<TopLine Value="286"/>
<UsageCount Value="3"/>
</Unit38>
<Unit39>
<Filename Value="..\..\..\..\lazarus211\fpc\2.1.1\source\rtl\inc\objpash.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="319"/>
<UsageCount Value="3"/>
</Unit39>
<Unit40>
<Filename Value="..\..\..\..\lazarus211\fpc\2.1.1\source\rtl\inc\getopts.pp"/>
<UnitName Value="getopts"/>
<CursorPos X="49" Y="203"/>
<TopLine Value="10"/>
<UsageCount Value="10"/>
</Unit48>
</Unit40>
<Unit41>
<Filename Value="..\..\..\..\lazarus211\fpc\2.1.1\source\packages\fcl-xml\src\dom.pp"/>
<UnitName Value="DOM"/>
<CursorPos X="27" Y="41"/>
<TopLine Value="1"/>
<UsageCount Value="9"/>
</Unit41>
<Unit42>
<Filename Value="..\..\..\..\lazarus211\fpc\2.1.1\source\packages\fcl-base\src\inc\avl_tree.pp"/>
<UnitName Value="AVL_Tree"/>
<CursorPos X="54" Y="156"/>
<TopLine Value="332"/>
<UsageCount Value="5"/>
</Unit42>
<Unit43>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\fcl\inc\contnrs.pp"/>
<UnitName Value="contnrs"/>
<CursorPos X="30" Y="685"/>
<TopLine Value="683"/>
<UsageCount Value="5"/>
</Unit43>
<Unit44>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\objpas\classes\lists.inc"/>
<CursorPos X="3" Y="29"/>
<TopLine Value="27"/>
<UsageCount Value="5"/>
</Unit44>
<Unit45>
<Filename Value="..\..\..\..\lazarusClean\fpc\2.0.4\source\rtl\objpas\sysutils\sysstr.inc"/>
<CursorPos X="1" Y="689"/>
<TopLine Value="686"/>
<UsageCount Value="26"/>
</Unit45>
</Units>
<JumpHistory Count="2" HistoryIndex="1">
<JumpHistory Count="9" HistoryIndex="8">
<Position1>
<Filename Value="generator.pas"/>
<Caret Line="427" Column="75" TopLine="414"/>
<Filename Value="wsdl2pas_imp.pas"/>
<Caret Line="1159" Column="12" TopLine="1136"/>
</Position1>
<Position2>
<Filename Value="generator.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="wsdl2pas_imp.pas"/>
<Caret Line="427" Column="11" TopLine="413"/>
</Position2>
<Position3>
<Filename Value="wsdl2pas_imp.pas"/>
<Caret Line="533" Column="32" TopLine="497"/>
</Position3>
<Position4>
<Filename Value="wsdl2pas_imp.pas"/>
<Caret Line="627" Column="22" TopLine="615"/>
</Position4>
<Position5>
<Filename Value="wsdl2pas_imp.pas"/>
<Caret Line="541" Column="52" TopLine="525"/>
</Position5>
<Position6>
<Filename Value="parserdefs.pas"/>
<Caret Line="333" Column="35" TopLine="312"/>
</Position6>
<Position7>
<Filename Value="parserdefs.pas"/>
<Caret Line="343" Column="34" TopLine="342"/>
</Position7>
<Position8>
<Filename Value="wsdl2pas_imp.pas"/>
<Caret Line="656" Column="66" TopLine="641"/>
</Position8>
<Position9>
<Filename Value="generator.pas"/>
<Caret Line="1837" Column="16" TopLine="1822"/>
</Position9>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -15,6 +15,7 @@ type
TWsdlParser = class;
TAbstractTypeParserClass = class of TAbstractTypeParser;
{ TAbstractTypeParser }
TAbstractTypeParser = class
@ -32,6 +33,16 @@ type
const ATypeName : string;
const AEmbededDef : Boolean
);
class function ExtractEmbeddedTypeFromElement(
AOwner : TWsdlParser;
AEltNode : TDOMNode;
ASymbols : TSymbolTable;
const ATypeName : string
) : TTypeDefinition;
class function GetParserSupportedStyle():string;virtual;abstract;
class procedure RegisterParser(AParserClass : TAbstractTypeParserClass);
class function GetRegisteredParserCount() : Integer;
class function GetRegisteredParser(const AIndex : Integer):TAbstractTypeParserClass;
function Parse():TTypeDefinition;virtual;abstract;
end;
@ -59,6 +70,7 @@ type
function ParseSimpleContent(const ATypeName : string):TTypeDefinition;
function ParseEmptyContent(const ATypeName : string):TTypeDefinition;
public
class function GetParserSupportedStyle():string;override;
function Parse():TTypeDefinition;override;
end;
@ -74,10 +86,11 @@ type
private
procedure CreateNodeCursors();
procedure ExtractTypeName();
procedure ExtractContentType();
function ExtractContentType() : Boolean;
function ParseEnumContent():TTypeDefinition;
function ParseOtherContent():TTypeDefinition;
public
class function GetParserSupportedStyle():string;override;
function Parse():TTypeDefinition;override;
end;
@ -101,15 +114,6 @@ type
FTypesCursor : IObjectCursor;
FSchemaCursor : IObjectCursor;
private
procedure CreateWsdlNameFilter(
AFltrCreator : TRttiFilterCreator;
const AName : WideString
);overload;
procedure CreateXsNameFilter(
AFltrCreator : TRttiFilterCreator;
const AName : WideString
);
function CreateWsdlNameFilter(const AName : WideString):IObjectFilter;
function FindNamedNode(AList : IObjectCursor; const AName : WideString):TDOMNode;
procedure Prepare();
@ -165,6 +169,7 @@ const
s_port : WideString = 'port';
s_portType : WideString = 'portType';
s_prohibited : WideString = 'prohibited';
s_ref : WideString = 'ref';
s_required : WideString = 'required';
s_restriction : WideString = 'restriction';
//s_return : WideString = 'return';
@ -222,28 +227,6 @@ begin
Result := Copy(Result,( i + 1 ), MaxInt);
end;
procedure CreateQualifiedNameFilter(
AFltrCreator : TRttiFilterCreator;
const AName : WideString;
APrefixList : TStrings
);
var
k : Integer;
locStr : string;
locWStr : WideString;
begin
AFltrCreator.Clear(clrFreeObjects);
for k := 0 to Pred(APrefixList.Count) do begin
if IsStrEmpty(APrefixList[k]) then
locWStr := ''
else
locWStr := APrefixList[k] + ':';
locWStr := locWStr + AName;
locStr := s_NODE_NAME;
AFltrCreator.AddCondition(locStr,sfoEqualCaseInsensitive,locWStr,fcOr);
end;
end;
function CreateQualifiedNameFilterStr(
const AName : WideString;
APrefixList : TStrings
@ -254,31 +237,27 @@ var
locWStr : WideString;
begin
Result := '';
for k := 0 to Pred(APrefixList.Count) do begin
if IsStrEmpty(APrefixList[k]) then
locWStr := ''
else
locWStr := APrefixList[k] + ':';
locWStr := locWStr + AName;
locStr := s_NODE_NAME;
Result := Result + ' or ' + locStr + ' = ' + QuotedStr(locWStr);
if ( APrefixList.Count > 0 ) then begin
for k := 0 to Pred(APrefixList.Count) do begin
if IsStrEmpty(APrefixList[k]) then begin
locWStr := ''
end else begin
locWStr := APrefixList[k] + ':';
end;
locWStr := locWStr + AName;
locStr := s_NODE_NAME;
Result := Result + ' or ' + locStr + ' = ' + QuotedStr(locWStr);
end;
if ( Length(Result) > 0 ) then begin
Delete(Result,1,Length(' or'));
end;
end else begin
Result := Format('%s = %s',[s_NODE_NAME,QuotedStr(AName)]);
end;
if ( Length(Result) > 0 ) then
Delete(Result,1,Length(' or'));
end;
{ TWsdlParser }
procedure TWsdlParser.CreateWsdlNameFilter(AFltrCreator : TRttiFilterCreator; const AName : WideString);
begin
CreateQualifiedNameFilter(AFltrCreator,AName,FWsdlShortNames);
end;
procedure TWsdlParser.CreateXsNameFilter(AFltrCreator: TRttiFilterCreator;const AName: WideString);
begin
CreateQualifiedNameFilter(AFltrCreator,AName,FXSShortNames);
end;
function TWsdlParser.CreateWsdlNameFilter(const AName: WideString): IObjectFilter;
begin
Result := ParseFilter(CreateQualifiedNameFilterStr(AName,FWsdlShortNames),TDOMNodeRttiExposer);
@ -330,6 +309,7 @@ begin
if AClearBefore then begin
AResList.Clear();
end;
AAttribCursor.Reset();
crs := CreateCursorOn(AAttribCursor,ParseFilter(Format('%s=%s',[s_NODE_VALUE,QuotedStr(ANameSpace)]),TDOMNodeRttiExposer));
crs.Reset();
if crs.MoveNext() then begin
@ -384,7 +364,7 @@ begin
ExtractNameSpaceShortNames(locAttCursor,FWsdlShortNames,s_wsdl,nfaRaiseException,True);
ExtractNameSpaceShortNames(locAttCursor,FSoapShortNames,s_soap,nfaRaiseException,False);
ExtractNameSpaceShortNames(locAttCursor,FXSShortNames,s_xs,nfaRaiseException,True);
ExtractNameSpaceShortNames(locAttCursor,FXSShortNames,s_xs,nfaNone,True);
FServiceCursor := CreateCursorOn(
FChildCursor.Clone() as IObjectCursor,
@ -558,6 +538,19 @@ begin
end;
end;
function StrToBindingStyle(const AStr : string):TBindingStyle;
begin
if IsStrEmpty(AStr) then begin
Result := bsDocument;
end else if AnsiSameText(AStr,s_document) then begin
Result := bsDocument;
end else if AnsiSameText(AStr,s_rpc) then begin
Result := bsRPC;
end else begin
Result := bsUnknown;
end;
end;
function TWsdlParser.ParsePortType(ANode, ABindingNode : TDOMNode) : TInterfaceDefinition;
function ExtractSoapBindingStyle(out AName : WideString):Boolean ;
@ -660,6 +653,7 @@ begin
locOpCursor.Reset();
ExtractSoapBindingStyle(locWStrBuffer);
locSoapBindingStyle := locWStrBuffer;
locIntf.BindingStyle := StrToBindingStyle(locSoapBindingStyle);
locBindingOperationCursor := ExtractBindingOperationCursor();
while locOpCursor.MoveNext() do begin
locObj := locOpCursor.GetCurrent() as TDOMNodeRttiExposer;
@ -1038,8 +1032,6 @@ end;
procedure TWsdlParser.ParseTypes();
var
locTypeCrs : IObjectCursor;
locObj : TDOMNodeRttiExposer;
nd : TDOMNodeRttiExposer;
schmCrsr, crsSchemaChild, typTmpCrs : IObjectCursor;
typFilterStr : string;
@ -1208,6 +1200,107 @@ begin
FEmbededDef := AEmbededDef;
end;
class function TAbstractTypeParser.ExtractEmbeddedTypeFromElement(
AOwner : TWsdlParser;
AEltNode : TDOMNode;
ASymbols : TSymbolTable;
const ATypeName : string
): TTypeDefinition;
function ExtractTypeName() : string;
var
locCrs : IObjectCursor;
begin
locCrs := CreateCursorOn(
CreateAttributesCursor(AEltNode,cetRttiNode),
ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_name)]),TDOMNodeRttiExposer)
);
locCrs.Reset();
if not locCrs.MoveNext() then
raise EWslParserException.Create('Unable to find the <name> tag in the type/element node attributes.');
Result := (locCrs.GetCurrent() as TDOMNodeRttiExposer).NodeValue;
if IsStrEmpty(Result) then begin
raise EWslParserException.Create('Invalid type/element name( the name is empty ).');
end;
end;
function FindParser(out AFoundTypeNode : TDOMNode):TAbstractTypeParserClass;
var
k : Integer;
locPrsClss : TAbstractTypeParserClass;
locFilter : string;
locCrs : IObjectCursor;
begin
Result := nil;
AFoundTypeNode := nil;
for k := 0 to Pred(GetRegisteredParserCount()) do begin
locPrsClss := GetRegisteredParser(k);
locFilter := locPrsClss.GetParserSupportedStyle();
if not IsStrEmpty(locFilter) then begin
locFilter := CreateQualifiedNameFilterStr(locFilter,AOwner.FXSShortNames);
locCrs := CreateCursorOn(CreateChildrenCursor(AEltNode,cetRttiNode),ParseFilter(locFilter,TDOMNodeRttiExposer));
locCrs.Reset();
if locCrs.MoveNext() then begin
AFoundTypeNode := (locCrs.GetCurrent() as TDOMNodeRttiExposer).InnerObject;
Result := locPrsClss;
Break;
end;
end;
end;
end;
var
typName : string;
prsClss : TAbstractTypeParserClass;
prs : TAbstractTypeParser;
typNode : TDOMNode;
begin
if not AEltNode.HasChildNodes() then begin;
raise EWslParserException.Create('Invalid type definition, this element must have children.');
end;
Result := nil;
typName := ATypeName;
if IsStrEmpty(typName) then begin
typName := ExtractTypeName();
end;
prsClss := FindParser(typNode);
if ( prsClss = nil ) then begin;
raise EWslParserException.CreateFmt('This type style is not supported : "%s".',[typName]);
end;
prs := prsClss.Create(AOwner,typNode,ASymbols,typName,True);
try
Result := prs.Parse();
finally
FreeAndNil(prs);
end;
end;
var
FTypeParserList : TClassList = nil;
class procedure TAbstractTypeParser.RegisterParser(AParserClass: TAbstractTypeParserClass);
begin
if ( FTypeParserList = nil ) then begin
FTypeParserList := TClassList.Create();
end;
if ( FTypeParserList.IndexOf(AParserClass) < 0 ) then begin
FTypeParserList.Add(AParserClass);
end;
end;
class function TAbstractTypeParser.GetRegisteredParserCount(): Integer;
begin
if Assigned(FTypeParserList) then begin
Result := FTypeParserList.Count;
end else begin
Result := 0;
end;
end;
class function TAbstractTypeParser.GetRegisteredParser(const AIndex: Integer): TAbstractTypeParserClass;
begin
Result := TAbstractTypeParserClass(FTypeParserList[AIndex]);
end;
{ TComplexTypeParser }
@ -1273,7 +1366,7 @@ procedure TComplexTypeParser.ExtractBaseType();
var
locContentChildCrs, locCrs : IObjectCursor;
locSymbol : TAbstractSymbolDefinition;
locBaseTypeName, locFilterStr : string;
locBaseTypeName, locBaseTypeInternalName, locFilterStr : string;
begin
locFilterStr := CreateQualifiedNameFilterStr(s_extension,FOwner.FXSShortNames);
locContentChildCrs := CreateChildrenCursor(FContentNode,cetRttiNode);
@ -1313,6 +1406,9 @@ begin
if Assigned(locSymbol) then begin
if locSymbol.InheritsFrom(TTypeDefinition) then begin
FBaseType := locSymbol as TTypeDefinition;
while Assigned(FBaseType) and FBaseType.InheritsFrom(TTypeAliasDefinition) do begin
FBaseType := (FBaseType as TTypeAliasDefinition).BaseType;
end;
if FBaseType.InheritsFrom(TNativeSimpleTypeDefinition) then begin
Assert(Assigned(TNativeSimpleTypeDefinition(FBaseType).BoxedType));
FBaseType := TNativeSimpleTypeDefinition(FBaseType).BoxedType;
@ -1321,7 +1417,12 @@ begin
raise EWslParserException.CreateFmt('"%s" was expected to be a type definition.',[locSymbol.Name]);
end;
end else begin
FBaseType := TForwardTypeDefinition.Create(locBaseTypeName);
locBaseTypeInternalName := ExtractIdentifier(locBaseTypeName);
if IsReservedKeyWord(locBaseTypeInternalName) then
locBaseTypeInternalName := '_' + locBaseTypeInternalName ;
FBaseType := TForwardTypeDefinition.Create(locBaseTypeInternalName);
if not AnsiSameText(locBaseTypeInternalName,locBaseTypeName) then
FBaseType.RegisterExternalAlias(locBaseTypeName);
FSymbols.Add(FBaseType);
end;
end;
@ -1388,7 +1489,7 @@ var
procedure ParseElement(AElement : TDOMNode);
var
locAttCursor, locPartCursor : IObjectCursor;
locName, locTypeName : string;
locName, locTypeName, locTypeInternalName : string;
locType : TAbstractSymbolDefinition;
locInternalEltName : string;
locProp : TPropertyDefinition;
@ -1396,25 +1497,54 @@ var
locMinOccur, locMaxOccur : Integer;
locMaxOccurUnbounded : Boolean;
locStrBuffer : string;
locIsRefElement : Boolean;
begin
locType := nil;
locTypeName := '';
locAttCursor := CreateAttributesCursor(AElement,cetRttiNode);
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_name)]),TDOMNodeRttiExposer));
locPartCursor.Reset();
if not locPartCursor.MoveNext() then
raise EWslParserException.Create('Invalid <element> definition : missing "name" attribute.');
locIsRefElement := False;
if not locPartCursor.MoveNext() then begin
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_ref)]),TDOMNodeRttiExposer));
locPartCursor.Reset();
if not locPartCursor.MoveNext() then begin
raise EWslParserException.Create('Invalid <element> definition : missing "name" or "ref" attribute.');
end;
locIsRefElement := True;
end;
locName := (locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue;
if locIsRefElement then begin
locName := ExtractNameFromQName(locName);
end;
if IsStrEmpty(locName) then
raise EWslParserException.Create('Invalid <element> definition : empty "name".');
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_type)]),TDOMNodeRttiExposer));
locPartCursor.Reset();
if not locPartCursor.MoveNext() then
raise EWslParserException.Create('Invalid <element> definition : missing "type" attribute.');
locTypeName := ExtractNameFromQName((locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue);
if locIsRefElement then begin
locTypeName := locName;
end else begin
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_type)]),TDOMNodeRttiExposer));
locPartCursor.Reset();
if locPartCursor.MoveNext() then begin
locTypeName := ExtractNameFromQName((locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue);
end else begin
locTypeName := Format('%s_%s_Type',[FTypeName,locName]);
locType := TAbstractTypeParser.ExtractEmbeddedTypeFromElement(FOwner,AElement,FSymbols,locTypeName);
if ( locType = nil ) then begin
raise EWslParserException.CreateFmt('Invalid <element> definition : unable to determine the type.'#13'Type name : "%s"; Element name :"%s".',[FTypeName,locName]);
end;
FSymbols.Add(locType);
end;
end;
if IsStrEmpty(locTypeName) then
raise EWslParserException.Create('Invalid <element> definition : empty "type".');
locType := FSymbols.Find(locTypeName);
if not Assigned(locType) then begin
locType := TForwardTypeDefinition.Create(locTypeName);
locTypeInternalName := locTypeName;
if IsReservedKeyWord(locTypeInternalName) then
locTypeInternalName := '_' + locTypeInternalName;
locType := TForwardTypeDefinition.Create(locTypeInternalName);
if not AnsiSameText(locTypeInternalName,locTypeName) then
locType.RegisterExternalAlias(locTypeName);
FSymbols.Add(locType);
end;
@ -1467,18 +1597,24 @@ var
var
locPropTyp : TPropertyDefinition;
k : Integer;
locString : string;
locSym : TAbstractSymbolDefinition;
begin
for k := 0 to Pred(AArrayPropList.Count) do begin
locPropTyp := AArrayPropList[k] as TPropertyDefinition;
FSymbols.Add(
TArrayDefinition.Create(
Format('%s_%sArray',[AClassName,locPropTyp.Name]),
locPropTyp.DataType,
locPropTyp.Name,
locPropTyp.ExternalName,
asEmbeded
)
);
locString := Format('%s_%sArray',[AClassName,locPropTyp.Name]);
locSym := FSymbols.Find(locString);
if ( locSym = nil ) then begin
FSymbols.Add(
TArrayDefinition.Create(
locString,
locPropTyp.DataType,
locPropTyp.Name,
locPropTyp.ExternalName,
asEmbeded
)
);
end;
end;
end;
@ -1558,13 +1694,20 @@ begin
ExtractBaseType();
eltCrs := ExtractElementCursor();
internalName := ATypeName;
hasInternalName := IsReservedKeyWord(internalName) or
( not IsValidIdent(internalName) );{ or
( FSymbols.IndexOf(internalName) <> -1 );}
if hasInternalName then
internalName := ExtractIdentifier(ATypeName);
{ while IsReservedKeyWord(internalName) or ( FSymbols.IndexOf(internalName) <> -1 ) do begin
internalName := Format('_%s',[internalName]);
end;
hasInternalName := ( not AnsiSameText(internalName,ATypeName) );
}
hasInternalName := IsReservedKeyWord(internalName) or
( not IsValidIdent(internalName) ) or
//( FSymbols.IndexOf(internalName) <> -1 ) or
( not AnsiSameText(internalName,ATypeName) );
if hasInternalName then begin
internalName := Format('_%s',[internalName]);
end;
if ( FDerivationMode = dmRestriction ) and FBaseType.SameName(s_array) then begin
Result := ExtractSoapArray(internalName,hasInternalName);
end else begin
@ -1789,6 +1932,11 @@ begin
);
end;
function TComplexTypeParser.GetParserSupportedStyle(): string;
begin
Result := s_complexType;
end;
function TComplexTypeParser.Parse() : TTypeDefinition;
var
locSym : TAbstractSymbolDefinition;
@ -1846,7 +1994,7 @@ begin
raise EWslParserException.Create('Invalid type name( the name is empty ).');
end;
procedure TSimpleTypeParser.ExtractContentType();
function TSimpleTypeParser.ExtractContentType() : Boolean;
var
locCrs, locAttCrs : IObjectCursor;
tmpNode : TDOMNode;
@ -1890,8 +2038,10 @@ begin
raise EWslParserException.CreateFmt('Base type is not specified for the simple type, parsing : "%s".',[FTypeName]);
FIsEnum := False
end;
Result := True;
end else begin
raise EWslParserException.CreateFmt('The parser only support "Restriction" mode simple type derivation, parsing : "%s".',[FTypeName]);
//raise EWslParserException.CreateFmt('The parser only support "Restriction" mode simple type derivation, parsing : "%s".',[FTypeName]);
Result := False;
end;
end;
@ -1916,6 +2066,7 @@ var
locCrs : IObjectCursor;
locItem : TEnumItemDefinition;
locHasInternalName : Boolean;
locBuffer : string;
begin
locCrs := CreateCursorOn(CreateAttributesCursor(AItemNode,cetRttiNode),ParseFilter(Format('%s=%s',[s_NODE_NAME,QuotedStr(s_value)]),TDOMNodeRttiExposer)) as IObjectCursor;
if not Assigned(locCrs) then
@ -1928,12 +2079,19 @@ var
if IsStrEmpty(locItemName) then
raise EWslParserException.CreateFmt('Invalid "enum" item node : the value attribute is empty, type = "%s".',[FTypeName]);
locInternalItemName := locItemName;
locInternalItemName := ExtractIdentifier(locItemName);
locHasInternalName := IsReservedKeyWord(locInternalItemName) or
( not IsValidIdent(locInternalItemName) ) or
( FSymbols.IndexOf(locInternalItemName) <> -1 );
if locHasInternalName then
locInternalItemName := Format('%s_%s',[locRes.ExternalName,locInternalItemName]);
( FSymbols.IndexOf(locInternalItemName) <> -1 ) or
( not AnsiSameText(locInternalItemName,locItemName) );
if locHasInternalName then begin
locBuffer := ExtractIdentifier(locRes.ExternalName);
if IsStrEmpty(locBuffer) and ( locBuffer[Length(locBuffer)] <> '_' ) then begin
locInternalItemName := Format('%s_%s',[locBuffer,locInternalItemName]);
end else begin
locInternalItemName := Format('%s%s',[locBuffer,locInternalItemName]);
end;
end;
locItem := TEnumItemDefinition.Create(locInternalItemName,locRes,locOrder);
if locHasInternalName then
locItem.RegisterExternalAlias(locItemName);
@ -1951,7 +2109,7 @@ begin
intrName := FTypeName;
hasIntrnName := IsReservedKeyWord(FTypeName) or
( FSymbols.IndexOf(intrName) < 0 );
( ( FSymbols.IndexOf(intrName) >= 0 ) and ( not FSymbols.ByName(intrName).InheritsFrom(TForwardTypeDefinition) ) );
if hasIntrnName then
intrName := '_' + intrName;
@ -1978,6 +2136,11 @@ begin // todo : implement TSimpleTypeParser.ParseOtherContent
Result := TTypeAliasDefinition.Create(FTypeName,FSymbols.ByName(FBaseName) as TTypeDefinition);
end;
function TSimpleTypeParser.GetParserSupportedStyle(): string;
begin
Result := s_simpleType;
end;
function TSimpleTypeParser.Parse(): TTypeDefinition;
var
locSym : TAbstractSymbolDefinition;
@ -1998,14 +2161,25 @@ begin
end;
end;
if locContinue then begin
ExtractContentType();
if FIsEnum then begin
Result := ParseEnumContent()
if ExtractContentType() then begin
if FIsEnum then begin
Result := ParseEnumContent()
end else begin
Result := ParseOtherContent();
end;
end else begin
FBaseName := 'string';
Result := ParseOtherContent();
end;
end;
end;
end.
initialization
TAbstractTypeParser.RegisterParser(TSimpleTypeParser);
TAbstractTypeParser.RegisterParser(TComplexTypeParser);
finalization
FreeAndNil(FTypeParserList);
end.

View File

@ -1,7 +1,9 @@
unit dom_cursors;
{$mode objfpc}{$H+}
//{$define FPC_211}
{$IF (FPC_VERSION = 2) and (FPC_RELEASE > 0)}
{$define FPC_211}
{$ENDIF}
interface
uses