You've already forked lazarus-ccr
Attributes cannot be array properties, Fix + test case.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4628 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
25
wst/trunk/tests/test_suite/files/att_inherited_maxbound.wsdl
Normal file
25
wst/trunk/tests/test_suite/files/att_inherited_maxbound.wsdl
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<definitions name="wst_test"
|
||||||
|
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
||||||
|
xmlns:tns="library1"
|
||||||
|
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:element name="TSampleType">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||||
|
<xsd:element name="StringElement" type="xsd:string" />
|
||||||
|
<xsd:element name="IntElement" type="xsd:int" />
|
||||||
|
</xsd:choice>
|
||||||
|
<xsd:attribute name="StringAtt" type="xsd:string" use="required" />
|
||||||
|
<xsd:attribute name="IntAtt" type="xsd:int" use="optional" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
</types>
|
||||||
|
|
||||||
|
|
||||||
|
</definitions>
|
17
wst/trunk/tests/test_suite/files/att_inherited_maxbound.xsd
Normal file
17
wst/trunk/tests/test_suite/files/att_inherited_maxbound.xsd
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?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:element name="TSampleType">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice minOccurs="1" maxOccurs="unbounded">
|
||||||
|
<xsd:element name="StringElement" type="xsd:string" />
|
||||||
|
<xsd:element name="IntElement" type="xsd:int" />
|
||||||
|
</xsd:choice>
|
||||||
|
<xsd:attribute name="StringAtt" type="xsd:string" use="required" />
|
||||||
|
<xsd:attribute name="IntAtt" type="xsd:int" use="optional" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
|
||||||
|
</xsd:schema>
|
@ -108,6 +108,7 @@ type
|
|||||||
function load_schema_default_elt_att_form_present() : TwstPasTreeContainer;virtual;abstract;
|
function load_schema_default_elt_att_form_present() : TwstPasTreeContainer;virtual;abstract;
|
||||||
|
|
||||||
function load_global_attribute() : TwstPasTreeContainer;virtual;abstract;
|
function load_global_attribute() : TwstPasTreeContainer;virtual;abstract;
|
||||||
|
function load_att_inherited_maxbound() : TwstPasTreeContainer;virtual;
|
||||||
published
|
published
|
||||||
procedure EmptySchema();
|
procedure EmptySchema();
|
||||||
|
|
||||||
@ -181,6 +182,7 @@ type
|
|||||||
procedure case_sensitive_import();
|
procedure case_sensitive_import();
|
||||||
|
|
||||||
procedure global_attribute();
|
procedure global_attribute();
|
||||||
|
procedure att_inherited_maxbound();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTest_XsdParser }
|
{ TTest_XsdParser }
|
||||||
@ -431,6 +433,11 @@ begin
|
|||||||
Result.DefaultSearchNameKinds := NAME_KINDS_DEFAULT;
|
Result.DefaultSearchNameKinds := NAME_KINDS_DEFAULT;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TTest_CustomXsdParser.load_att_inherited_maxbound : TwstPasTreeContainer;
|
||||||
|
begin
|
||||||
|
Result := ParseDoc('att_inherited_maxbound');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTest_CustomXsdParser.EmptySchema();
|
procedure TTest_CustomXsdParser.EmptySchema();
|
||||||
var
|
var
|
||||||
tr : TwstPasTreeContainer;
|
tr : TwstPasTreeContainer;
|
||||||
@ -4083,6 +4090,61 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTest_CustomXsdParser.att_inherited_maxbound();
|
||||||
|
const s_class_name = 'TSampleType';
|
||||||
|
var
|
||||||
|
clsType : TPasClassType;
|
||||||
|
tr : TwstPasTreeContainer;
|
||||||
|
|
||||||
|
procedure CheckProperty(
|
||||||
|
const AName,
|
||||||
|
ADeclaredName,
|
||||||
|
ATypeName : string;
|
||||||
|
const AFieldType : TPropertyType;
|
||||||
|
const AIsArray : Boolean
|
||||||
|
);
|
||||||
|
var
|
||||||
|
prp : TPasProperty;
|
||||||
|
t : TPasType;
|
||||||
|
begin
|
||||||
|
prp := FindMember(clsType,AName) as TPasProperty;
|
||||||
|
CheckNotNull(prp);
|
||||||
|
CheckEquals(AName,prp.Name,'Name');
|
||||||
|
CheckEquals(ADeclaredName,tr.GetExternalName(prp),'External Name');
|
||||||
|
CheckNotNull(prp.VarType);
|
||||||
|
t := GetUltimeType(prp.VarType);
|
||||||
|
CheckNotNull(t,'Property''s Ultime Type not found.');
|
||||||
|
if AIsArray then begin
|
||||||
|
CheckEquals(AIsArray,(t is TPasArrayType));
|
||||||
|
CheckNotNull(TPasArrayType(t).ElType,'array element type');
|
||||||
|
CheckEquals(ATypeName,tr.GetExternalName(TPasArrayType(t).ElType),'TypeName');
|
||||||
|
end else begin
|
||||||
|
CheckEquals(ATypeName,tr.GetExternalName(t),'TypeName');
|
||||||
|
end;
|
||||||
|
CheckEquals(PropertyType_Att[AFieldType],tr.IsAttributeProperty(prp));
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
mdl : TPasModule;
|
||||||
|
elt : TPasElement;
|
||||||
|
begin
|
||||||
|
tr := load_att_inherited_maxbound();
|
||||||
|
try
|
||||||
|
mdl := tr.FindModule('urn:wst-test');
|
||||||
|
CheckNotNull(mdl,'urn:wst-test');
|
||||||
|
elt := tr.FindElement(s_class_name);
|
||||||
|
CheckNotNull(elt,s_class_name);
|
||||||
|
CheckIs(elt,TPasClassType);
|
||||||
|
clsType := elt as TPasClassType;
|
||||||
|
CheckProperty('StringElement','StringElement','string',ptField,True);
|
||||||
|
CheckProperty('IntElement','IntElement','int',ptField,True);
|
||||||
|
CheckProperty('StringAtt','StringAtt','string',ptAttribute,False);
|
||||||
|
CheckProperty('IntAtt','IntAtt','int',ptAttribute,False);
|
||||||
|
finally
|
||||||
|
tr.Free();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TTest_XsdParser }
|
{ TTest_XsdParser }
|
||||||
|
|
||||||
function TTest_XsdParser.ParseDoc(
|
function TTest_XsdParser.ParseDoc(
|
||||||
|
@ -1234,33 +1234,37 @@ var
|
|||||||
locProp.StoredAccessorName := 'True';
|
locProp.StoredAccessorName := 'True';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if ABoundInfos.Valid then begin
|
if locIsAttribute then begin
|
||||||
locMaxOccur := ABoundInfos.MaxOccurs;
|
|
||||||
locMaxOccurUnbounded := ABoundInfos.Unboundded;
|
|
||||||
end else begin
|
|
||||||
locMaxOccur := 1;
|
locMaxOccur := 1;
|
||||||
locMaxOccurUnbounded := False;
|
locMaxOccurUnbounded := False;
|
||||||
end;
|
end else begin
|
||||||
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_maxOccurs)]),TDOMNodeRttiExposer));
|
if ABoundInfos.Valid then begin
|
||||||
locPartCursor.Reset();
|
locMaxOccur := ABoundInfos.MaxOccurs;
|
||||||
if locPartCursor.MoveNext() then begin
|
locMaxOccurUnbounded := ABoundInfos.Unboundded;
|
||||||
locStrBuffer := (locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue;
|
|
||||||
if AnsiSameText(locStrBuffer,s_unbounded) then begin
|
|
||||||
locMaxOccurUnbounded := True;
|
|
||||||
end else begin
|
end else begin
|
||||||
if not TryStrToInt(locStrBuffer,locMaxOccur) then
|
locMaxOccur := 1;
|
||||||
raise EXsdParserException.CreateFmt(SERR_InvalidMaxOccursValue,[FTypeName,locName]);
|
locMaxOccurUnbounded := False;
|
||||||
if ( locMinOccur < 0 ) then
|
end;
|
||||||
raise EXsdParserException.CreateFmt(SERR_InvalidMaxOccursValue,[FTypeName,locName]);
|
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_maxOccurs)]),TDOMNodeRttiExposer));
|
||||||
|
locPartCursor.Reset();
|
||||||
|
if locPartCursor.MoveNext() then begin
|
||||||
|
locStrBuffer := (locPartCursor.GetCurrent() as TDOMNodeRttiExposer).NodeValue;
|
||||||
|
if AnsiSameText(locStrBuffer,s_unbounded) then begin
|
||||||
|
locMaxOccurUnbounded := True;
|
||||||
|
end else begin
|
||||||
|
if not TryStrToInt(locStrBuffer,locMaxOccur) then
|
||||||
|
raise EXsdParserException.CreateFmt(SERR_InvalidMaxOccursValue,[FTypeName,locName]);
|
||||||
|
if ( locMinOccur < 0 ) then
|
||||||
|
raise EXsdParserException.CreateFmt(SERR_InvalidMaxOccursValue,[FTypeName,locName]);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
isArrayDef := locMaxOccurUnbounded or ( locMaxOccur > 1 );
|
isArrayDef := not(locIsAttribute) and (locMaxOccurUnbounded or (locMaxOccur > 1));
|
||||||
if isArrayDef then begin
|
if isArrayDef then begin
|
||||||
arrayItems.Add(locProp).FIsCollection := IsCollectionArray(AElement);
|
arrayItems.Add(locProp).FIsCollection := IsCollectionArray(AElement);
|
||||||
end;
|
end;
|
||||||
if AnsiSameText(s_attribute,ExtractNameFromQName(AElement.NodeName)) then begin
|
if locIsAttribute then
|
||||||
FSymbols.SetPropertyAsAttribute(locProp,True);
|
FSymbols.SetPropertyAsAttribute(locProp,True);
|
||||||
end;
|
|
||||||
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_default)]),TDOMNodeRttiExposer));
|
locPartCursor := CreateCursorOn(locAttCursor.Clone() as IObjectCursor,ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_default)]),TDOMNodeRttiExposer));
|
||||||
locPartCursor.Reset();
|
locPartCursor.Reset();
|
||||||
if locPartCursor.MoveNext() then
|
if locPartCursor.MoveNext() then
|
||||||
|
Reference in New Issue
Block a user