XSD <any> and <anyAttribute> handling

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@598 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2008-10-23 19:21:59 +00:00
parent cfba265867
commit 83f0425897
10 changed files with 817 additions and 44 deletions

View File

@ -0,0 +1,54 @@
<?xml version="1.0"?>
<definitions name="wst_test"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="urn:wst-test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
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">
<xsd:complexType name="TClass_1">
<xsd:sequence>
<xsd:element name="intField" type="xsd:int" />
<xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:anyAttribute processContents="strict"/>
</xsd:complexType>
<xsd:complexType name="TClassSampleTypeAll">
<xsd:all>
<xsd:element name="intField" type="xsd:int" />
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
</xsd:all>
<xsd:attribute name="strAtt" type="xsd:string"/>
<xsd:anyAttribute processContents="skip"/>
</xsd:complexType>
<xsd:complexType name="TClass_2">
<xsd:sequence>
<xsd:element name="SomeField" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TClassSampleDerivedType">
<xsd:complexContent>
<xsd:extension base="tns:TClass_2">
<xsd:sequence>
<xsd:element name="intFieldEx" type="xsd:int" />
<xsd:element name="strFieldEx" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:any processContents="skip" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="strAttEx" type="xsd:string"/>
<xsd:attribute name="intAttEx" type="xsd:int"/>
<xsd:anyAttribute processContents="lax"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
</definitions>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:n="urn:wst-test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:wst-test">
<xsd:complexType name="TClass_1">
<xsd:sequence>
<xsd:element name="intField" type="xsd:int" />
<xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:anyAttribute processContents="strict"/>
</xsd:complexType>
<xsd:complexType name="TClassSampleTypeAll">
<xsd:all>
<xsd:element name="intField" type="xsd:int" />
<xsd:element name="strField" type="xsd:string" minOccurs="1" maxOccurs="1"/>
</xsd:all>
<xsd:attribute name="strAtt" type="xsd:string"/>
<xsd:anyAttribute processContents="skip"/>
</xsd:complexType>
<xsd:complexType name="TClass_2">
<xsd:sequence>
<xsd:element name="SomeField" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TClassSampleDerivedType">
<xsd:complexContent>
<xsd:extension base="n:TClass_2">
<xsd:sequence>
<xsd:element name="intFieldEx" type="xsd:int" />
<xsd:element name="strFieldEx" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:any processContents="skip" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="strAttEx" type="xsd:string"/>
<xsd:attribute name="intAttEx" type="xsd:int"/>
<xsd:anyAttribute processContents="lax"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>

View File

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<schema xmlns:tns="urn:wst-test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:wst-test">
<xsd:complexType name="TComplexType">
<xsd:sequence>
<xsd:any maxOccurs="unbounded" minOccurs="0" processContents="lax"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TComplexType2">
<xsd:sequence>
<xsd:element name="strField" type="xsd:string"/>
<xsd:any maxOccurs="unbounded" minOccurs="0" processContents="lax"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TComplexTypeParent">
<xsd:sequence>
<xsd:element name="strFieldParent" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TComplexTypeChild">
<xsd:extension base="tns:TComplexTypeParent">
<xsd:sequence>
<xsd:element name="strFieldChild" type="xsd:string"/>
<xsd:any maxOccurs="10" minOccurs="2" processContents="skip"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexType>
</schema>

View File

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<schema xmlns:tns="urn:wst-test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:wst-test">
<xsd:complexType name="TComplexType">
<xsd:sequence>
<xsd:any maxOccurs="unbounded" minOccurs="0" processContents="lax"/>
</xsd:sequence>
<xsd:anyAttribute processContents="lax"/>
</xsd:complexType>
<xsd:complexType name="TComplexType2">
<xsd:sequence>
<xsd:element name="strField" type="xsd:string"/>
<xsd:element name="strFieldAtt" type="xsd:string"/>
<xsd:any maxOccurs="unbounded" minOccurs="0" processContents="lax"/>
</xsd:sequence>
<xsd:anyAttribute processContents="strict"/>
</xsd:complexType>
<xsd:complexType name="TComplexTypeParent">
<xsd:sequence>
<xsd:element name="strFieldParent" type="xsd:string"/>
<xsd:element name="strFieldParentAtt" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TComplexTypeChild">
<xsd:extension base="tns:TComplexTypeParent">
<xsd:sequence>
<xsd:element name="strFieldChild" type="xsd:string"/>
<xsd:element name="strFieldChildAtt" type="xsd:string"/>
<xsd:any maxOccurs="10" minOccurs="2" processContents="skip"/>
</xsd:sequence>
</xsd:extension>
<xsd:anyAttribute processContents="skip"/>
</xsd:complexType>
</schema>

View File

@ -0,0 +1,28 @@
<?xml version="1.0"?>
<schema xmlns:tns="urn:wst-test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:wst-test">
<xsd:complexType name="TComplexType">
<xsd:anyAttribute processContents="lax"/>
</xsd:complexType>
<xsd:complexType name="TComplexType2">
<xsd:sequence>
<xsd:element name="strField" type="xsd:string"/>
<xsd:element name="strFieldAtt" type="xsd:string"/>
</xsd:sequence>
<xsd:anyAttribute processContents="strict"/>
</xsd:complexType>
<xsd:complexType name="TComplexTypeParent">
<xsd:sequence>
<xsd:element name="strFieldParent" type="xsd:string"/>
<xsd:element name="strFieldParentAtt" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TComplexTypeChild">
<xsd:extension base="tns:TComplexTypeParent">
<xsd:sequence>
<xsd:element name="strFieldChild" type="xsd:string"/>
<xsd:element name="strFieldChildAtt" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
<xsd:anyAttribute processContents="skip"/>
</xsd:complexType>
</schema>

View File

@ -44,6 +44,9 @@ type
{$ENDIF WST_UNICODESTRING}
procedure array_sequence_collection();
procedure class_sequence_open_type_any();
procedure class_sequence_open_type_any_attribute();
procedure class_sequence_open_type_any_any_attribute();
end;
TTest_XsdGenerator = class(TTest_CustomXsdGenerator)
@ -565,6 +568,279 @@ begin
end;
end;
procedure TTest_CustomXsdGenerator.class_sequence_open_type_any();
var
tr : TwstPasTreeContainer;
procedure AddProperty(
AClassType : TPasClassType;
const AName,
ATypeName : string;
const AKind : TPropertyType
);
var
p : TPasProperty;
begin
p := TPasProperty(tr.CreateElement(TPasProperty,AName,AClassType,visDefault,'',0));
AClassType.Members.Add(p);
p.ReadAccessorName := 'F' + AName;
p.WriteAccessorName := 'F' + AName;
p.VarType := tr.FindElement(ATypeName) as TPasType;
Check( (p.VarType <> nil), Format('Type not found : "%s".',[ATypeName]));
p.VarType.AddRef();
p.Visibility := visPublished;
p.StoredAccessorName := 'True';
if ( AKind = ptAttribute ) then
tr.SetPropertyAsAttribute(p,True);
end;
var
mdl : TPasModule;
cltyp : TPasClassType;
g : IGenerator;
locDoc, locExistDoc : TXMLDocument;
begin
locDoc := nil;
locExistDoc := nil;
tr := TwstPasTreeContainer.Create();
try
CreateWstInterfaceSymbolTable(tr);
mdl := TPasModule(tr.CreateElement(TPasModule,'open_type_module',tr.Package,visDefault,'',0));
tr.RegisterExternalAlias(mdl,'urn:wst-test');
tr.Package.Modules.Add(mdl);
mdl.InterfaceSection := TPasSection(tr.CreateElement(TPasSection,'',mdl,visDefault,'',0));
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexType',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElementNS('TBaseComplexRemotable',s_xs) as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_any]),'processContents=lax;minOccurs=0;maxOccurs=unbounded');
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexType2',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElementNS('TBaseComplexRemotable',s_xs) as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_any]),'processContents=lax;minOccurs=0;maxOccurs=unbounded');
AddProperty(cltyp,'strField','string',ptField);
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexTypeParent',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElementNS('TBaseComplexRemotable',s_xs) as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
AddProperty(cltyp,'strFieldParent','string',ptField);
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexTypeChild',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElement('TComplexTypeParent') as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_any]),'processContents=skip;minOccurs=2;maxOccurs=10');
AddProperty(cltyp,'strFieldChild','string',ptField);
locDoc := CreateDoc();
g := CreateGenerator(locDoc);
g.Execute(tr,mdl.Name);
//WriteXML(locDoc,'gen_class_sequence_open_type_any.xsd');
locExistDoc := LoadXmlFromFilesList('gen_class_sequence_open_type_any.xsd');
Check(CompareNodes(locExistDoc.DocumentElement,locDoc.DocumentElement),'generated document differs from the existent one.');
finally
ReleaseDomNode(locExistDoc);
ReleaseDomNode(locDoc);
FreeAndNil(tr);
end;
end;
procedure TTest_CustomXsdGenerator.class_sequence_open_type_any_attribute();
var
tr : TwstPasTreeContainer;
procedure AddProperty(
AClassType : TPasClassType;
const AName,
ATypeName : string;
const AKind : TPropertyType
);
var
p : TPasProperty;
begin
p := TPasProperty(tr.CreateElement(TPasProperty,AName,AClassType,visDefault,'',0));
AClassType.Members.Add(p);
p.ReadAccessorName := 'F' + AName;
p.WriteAccessorName := 'F' + AName;
p.VarType := tr.FindElement(ATypeName) as TPasType;
Check( (p.VarType <> nil), Format('Type not found : "%s".',[ATypeName]));
p.VarType.AddRef();
p.Visibility := visPublished;
p.StoredAccessorName := 'True';
if ( AKind = ptAttribute ) then
tr.SetPropertyAsAttribute(p,True);
end;
var
mdl : TPasModule;
cltyp : TPasClassType;
g : IGenerator;
locDoc, locExistDoc : TXMLDocument;
begin
locDoc := nil;
locExistDoc := nil;
tr := TwstPasTreeContainer.Create();
try
CreateWstInterfaceSymbolTable(tr);
mdl := TPasModule(tr.CreateElement(TPasModule,'open_type_module',tr.Package,visDefault,'',0));
tr.RegisterExternalAlias(mdl,'urn:wst-test');
tr.Package.Modules.Add(mdl);
mdl.InterfaceSection := TPasSection(tr.CreateElement(TPasSection,'',mdl,visDefault,'',0));
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexType',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElementNS('TBaseComplexRemotable',s_xs) as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_anyAttribute]),'processContents=lax');
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexType2',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElementNS('TBaseComplexRemotable',s_xs) as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_anyAttribute]),'processContents=strict');
AddProperty(cltyp,'strField','string',ptField);
AddProperty(cltyp,'strFieldAtt','string',ptField);
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexTypeParent',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElementNS('TBaseComplexRemotable',s_xs) as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
AddProperty(cltyp,'strFieldParent','string',ptField);
AddProperty(cltyp,'strFieldParentAtt','string',ptField);
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexTypeChild',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElement('TComplexTypeParent') as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_anyAttribute]),'processContents=skip');
AddProperty(cltyp,'strFieldChild','string',ptField);
AddProperty(cltyp,'strFieldChildAtt','string',ptField);
locDoc := CreateDoc();
g := CreateGenerator(locDoc);
g.Execute(tr,mdl.Name);
//WriteXML(locDoc,'gen_class_sequence_open_type_any_attribute.xsd');
locExistDoc := LoadXmlFromFilesList('gen_class_sequence_open_type_any_attribute.xsd');
Check(CompareNodes(locExistDoc.DocumentElement,locDoc.DocumentElement),'generated document differs from the existent one.');
finally
ReleaseDomNode(locExistDoc);
ReleaseDomNode(locDoc);
FreeAndNil(tr);
end;
end;
procedure TTest_CustomXsdGenerator.class_sequence_open_type_any_any_attribute();
var
tr : TwstPasTreeContainer;
procedure AddProperty(
AClassType : TPasClassType;
const AName,
ATypeName : string;
const AKind : TPropertyType
);
var
p : TPasProperty;
begin
p := TPasProperty(tr.CreateElement(TPasProperty,AName,AClassType,visDefault,'',0));
AClassType.Members.Add(p);
p.ReadAccessorName := 'F' + AName;
p.WriteAccessorName := 'F' + AName;
p.VarType := tr.FindElement(ATypeName) as TPasType;
Check( (p.VarType <> nil), Format('Type not found : "%s".',[ATypeName]));
p.VarType.AddRef();
p.Visibility := visPublished;
p.StoredAccessorName := 'True';
if ( AKind = ptAttribute ) then
tr.SetPropertyAsAttribute(p,True);
end;
var
mdl : TPasModule;
cltyp : TPasClassType;
g : IGenerator;
locDoc, locExistDoc : TXMLDocument;
begin
locDoc := nil;
locExistDoc := nil;
tr := TwstPasTreeContainer.Create();
try
CreateWstInterfaceSymbolTable(tr);
mdl := TPasModule(tr.CreateElement(TPasModule,'open_type_module',tr.Package,visDefault,'',0));
tr.RegisterExternalAlias(mdl,'urn:wst-test');
tr.Package.Modules.Add(mdl);
mdl.InterfaceSection := TPasSection(tr.CreateElement(TPasSection,'',mdl,visDefault,'',0));
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexType',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElementNS('TBaseComplexRemotable',s_xs) as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_anyAttribute]),'processContents=lax');
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_any]),'processContents=lax;minOccurs=0;maxOccurs=unbounded');
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexType2',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElementNS('TBaseComplexRemotable',s_xs) as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_anyAttribute]),'processContents=strict');
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_any]),'processContents=lax;minOccurs=0;maxOccurs=unbounded');
AddProperty(cltyp,'strField','string',ptField);
AddProperty(cltyp,'strFieldAtt','string',ptField);
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexTypeParent',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElementNS('TBaseComplexRemotable',s_xs) as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
AddProperty(cltyp,'strFieldParent','string',ptField);
AddProperty(cltyp,'strFieldParentAtt','string',ptField);
cltyp := TPasClassType(tr.CreateElement(TPasClassType,'TComplexTypeChild',mdl.InterfaceSection,visDefault,'',0));
cltyp.ObjKind := okClass;
cltyp.AncestorType := tr.FindElement('TComplexTypeParent') as TPasType;
cltyp.AncestorType.AddRef();
mdl.InterfaceSection.Declarations.Add(cltyp);
mdl.InterfaceSection.Types.Add(cltyp);
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_anyAttribute]),'processContents=skip');
tr.Properties.SetValue(cltyp,Format('%s#%s',[s_xs,s_any]),'processContents=skip;minOccurs=2;maxOccurs=10');
AddProperty(cltyp,'strFieldChild','string',ptField);
AddProperty(cltyp,'strFieldChildAtt','string',ptField);
locDoc := CreateDoc();
g := CreateGenerator(locDoc);
g.Execute(tr,mdl.Name);
//WriteXML(locDoc,'gen_class_sequence_open_type_any_anyatt.xsd');
locExistDoc := LoadXmlFromFilesList('gen_class_sequence_open_type_any_anyatt.xsd');
Check(CompareNodes(locExistDoc.DocumentElement,locDoc.DocumentElement),'generated document differs from the existent one.');
finally
ReleaseDomNode(locExistDoc);
ReleaseDomNode(locDoc);
FreeAndNil(tr);
end;
end;
function TTest_CustomXsdGenerator.LoadXmlFromFilesList(const AFileName: string): TXMLDocument;
begin
ReadXMLFile(Result,wstExpandLocalFileName(TestFilesPath + AFileName));

View File

@ -40,6 +40,7 @@ type
function LoadComplexType_Class_properties_extended_metadata2() : TwstPasTreeContainer;virtual;abstract;
function LoadComplexType_Class_Embedded_Schema() : TwstPasTreeContainer;virtual;abstract;
function LoadComplexType_Class_Extend_Simple_Schema() : TwstPasTreeContainer;virtual;abstract;
function LoadComplexType_Class_OpenType() : TwstPasTreeContainer;virtual;abstract;
function LoadComplexType_Record_Schema() : TwstPasTreeContainer;virtual;abstract;
function LoadComplexType_Record_Embedded_Schema() : TwstPasTreeContainer;virtual;abstract;
@ -68,6 +69,11 @@ type
procedure ComplexType_Class_properties_extended_metadata2();
procedure ComplexType_Class_Embedded();
procedure ComplexType_Class_Extend_Simple_Schema();
procedure ComplexType_Class_open_type_any();
procedure ComplexType_Class_open_extension_type_any();
procedure ComplexType_Class_open_extension_type_anyAttribute();
procedure ComplexType_Class_sequence_open_type_anyAttribute();
procedure ComplexType_Class_all_open_type_anyAttribute();
procedure ComplexType_Record();
procedure ComplexType_Record_Embedded();
@ -102,6 +108,7 @@ type
function LoadComplexType_Class_properties_extended_metadata2() : TwstPasTreeContainer;override;
function LoadComplexType_Class_Embedded_Schema() : TwstPasTreeContainer;override;
function LoadComplexType_Class_Extend_Simple_Schema() : TwstPasTreeContainer;override;
function LoadComplexType_Class_OpenType() : TwstPasTreeContainer;override;
function LoadComplexType_Record_Schema() : TwstPasTreeContainer;override;
function LoadComplexType_Record_Embedded_Schema() : TwstPasTreeContainer;override;
@ -137,6 +144,7 @@ type
function LoadComplexType_Class_Schema() : TwstPasTreeContainer;override;
function LoadComplexType_Class_Embedded_Schema() : TwstPasTreeContainer;override;
function LoadComplexType_Class_Extend_Simple_Schema() : TwstPasTreeContainer;override;
function LoadComplexType_Class_OpenType() : TwstPasTreeContainer;override;
function LoadComplexType_Record_Schema() : TwstPasTreeContainer;override;
function LoadComplexType_Record_Embedded_Schema() : TwstPasTreeContainer;override;
@ -162,7 +170,7 @@ type
end;
implementation
uses parserutils;
uses parserutils, xsd_consts;
const
x_complexType_SampleArrayIntFieldType = 'TArrayIntFieldType';
@ -685,6 +693,149 @@ begin
end;
end;
procedure TTest_CustomXsdParser.ComplexType_Class_open_type_any();
var
tr : TwstPasTreeContainer;
clsType : TPasClassType;
mdl : TPasModule;
elt : TPasElement;
strBuffer : string;
ls : TStringList;
begin
tr := LoadComplexType_Class_OpenType();
mdl := tr.FindModule(x_targetNamespace);
CheckNotNull(mdl);
elt := tr.FindElement('TClass_1');
CheckNotNull(elt,'TClass_1');
CheckIs(elt,TPasClassType);
clsType := elt as TPasClassType;
strBuffer := tr.Properties.GetValue(clsType,Format('%s#%s',[s_xs,s_any]));
Check(Length(strBuffer) > 0, s_any);
ls := TStringList.Create();
try
ls.Delimiter := ';';
ls.DelimitedText := strBuffer;
CheckEquals('lax',ls.Values[s_processContents]);
CheckEquals('0',ls.Values[s_minOccurs]);
CheckEquals(s_unbounded,ls.Values[s_maxOccurs]);
finally
ls.Free();
end;
end;
procedure TTest_CustomXsdParser.ComplexType_Class_open_extension_type_any();
var
tr : TwstPasTreeContainer;
clsType : TPasClassType;
mdl : TPasModule;
elt : TPasElement;
strBuffer : string;
ls : TStringList;
begin
tr := LoadComplexType_Class_OpenType();
mdl := tr.FindModule(x_targetNamespace);
CheckNotNull(mdl);
elt := tr.FindElement('TClassSampleDerivedType');
CheckNotNull(elt,'TClassSampleDerivedType');
CheckIs(elt,TPasClassType);
clsType := elt as TPasClassType;
strBuffer := tr.Properties.GetValue(clsType,Format('%s#%s',[s_xs,s_any]));
Check(Length(strBuffer) > 0, s_any);
ls := TStringList.Create();
try
ls.Delimiter := ';';
ls.DelimitedText := strBuffer;
CheckEquals('skip',ls.Values[s_processContents]);
CheckEquals(s_unbounded,ls.Values[s_maxOccurs]);
finally
ls.Free();
end;
end;
procedure TTest_CustomXsdParser.ComplexType_Class_open_extension_type_anyAttribute();
var
tr : TwstPasTreeContainer;
clsType : TPasClassType;
mdl : TPasModule;
elt : TPasElement;
strBuffer : string;
ls : TStringList;
begin
tr := LoadComplexType_Class_OpenType();
mdl := tr.FindModule(x_targetNamespace);
CheckNotNull(mdl);
elt := tr.FindElement('TClassSampleDerivedType');
CheckNotNull(elt,'TClassSampleDerivedType');
CheckIs(elt,TPasClassType);
clsType := elt as TPasClassType;
strBuffer := tr.Properties.GetValue(clsType,Format('%s#%s',[s_xs,s_anyAttribute]));
Check(Length(strBuffer) > 0, s_anyAttribute);
ls := TStringList.Create();
try
ls.Delimiter := ';';
ls.DelimitedText := strBuffer;
CheckEquals('lax',ls.Values[s_processContents]);
finally
ls.Free();
end;
end;
procedure TTest_CustomXsdParser.ComplexType_Class_sequence_open_type_anyAttribute();
var
tr : TwstPasTreeContainer;
clsType : TPasClassType;
mdl : TPasModule;
elt : TPasElement;
strBuffer : string;
ls : TStringList;
begin
tr := LoadComplexType_Class_OpenType();
mdl := tr.FindModule(x_targetNamespace);
CheckNotNull(mdl);
elt := tr.FindElement('TClass_1');
CheckNotNull(elt,'TClass_1');
CheckIs(elt,TPasClassType);
clsType := elt as TPasClassType;
strBuffer := tr.Properties.GetValue(clsType,Format('%s#%s',[s_xs,s_anyAttribute]));
Check(Length(strBuffer) > 0, s_anyAttribute);
ls := TStringList.Create();
try
ls.Delimiter := ';';
ls.DelimitedText := strBuffer;
CheckEquals('strict',ls.Values[s_processContents]);
finally
ls.Free();
end;
end;
procedure TTest_CustomXsdParser.ComplexType_Class_all_open_type_anyAttribute();
var
tr : TwstPasTreeContainer;
clsType : TPasClassType;
mdl : TPasModule;
elt : TPasElement;
strBuffer : string;
ls : TStringList;
begin
tr := LoadComplexType_Class_OpenType();
mdl := tr.FindModule(x_targetNamespace);
CheckNotNull(mdl);
elt := tr.FindElement('TClassSampleTypeAll');
CheckNotNull(elt,'TClassSampleTypeAll');
CheckIs(elt,TPasClassType);
clsType := elt as TPasClassType;
strBuffer := tr.Properties.GetValue(clsType,Format('%s#%s',[s_xs,s_anyAttribute]));
Check(Length(strBuffer) > 0, s_anyAttribute);
ls := TStringList.Create();
try
ls.Delimiter := ';';
ls.DelimitedText := strBuffer;
CheckEquals('skip',ls.Values[s_processContents]);
finally
ls.Free();
end;
end;
procedure TTest_CustomXsdParser.ComplexType_Record();
var
tr : TwstPasTreeContainer;
@ -1417,7 +1568,7 @@ begin
end;
end;
procedure TTest_CustomXsdParser.ComplexType_Class_properties_extended_metadata2;
procedure TTest_CustomXsdParser.ComplexType_Class_properties_extended_metadata2();
const s_ProjectType = 'ProjectType';
var
tr : TwstPasTreeContainer;
@ -1515,6 +1666,11 @@ begin
Result := ParseDoc(x_complexType_extend_simple);
end;
function TTest_XsdParser.LoadComplexType_Class_OpenType( ): TwstPasTreeContainer;
begin
Result := ParseDoc('complex_class_open_type');
end;
function TTest_XsdParser.LoadComplexType_Record_Schema(): TwstPasTreeContainer;
begin
Result := ParseDoc(x_complexType_record);
@ -1635,6 +1791,11 @@ begin
Result := ParseDoc(x_complexType_extend_simple);
end;
function TTest_WsdlParser.LoadComplexType_Class_OpenType(): TwstPasTreeContainer;
begin
Result := ParseDoc('complex_class_open_type');
end;
function TTest_WsdlParser.LoadComplexType_Record_Schema(): TwstPasTreeContainer;
begin
Result := ParseDoc(x_complexType_record);