[xsd-users] Problem with substition groups
FLACHET Nicolas
Nicolas.FLACHET at cstb.fr
Thu Nov 30 05:02:09 EST 2017
Hello Boris,
Thank you, but I read and re-read the documentation and I understand that elements are not part of the generated code.
However, in the generciApplicationOf substitution mecanism of cityGML, I have no choice on the xsd file.
for exemple with the previous xsd samplecode :
<xs:complexType name="AbstractBuildingType" abstract="true">
<xs:complexContent>
<xs:extension base="core:AbstractSiteType">
<xs:sequence>
<xs:element ref="_GenericApplicationPropertyOfAbstractBuilding" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="_GenericApplicationPropertyOfAbstractBuilding" type="xs:anyType" abstract="true"/>
<xs:element name="Truitos" type="integer" substitutionGroup="_GenericApplicationPropertyOfAbstractBuilding"/>
I've got a generated building with a list type of xml_schema::type for _GenericApplicationPropertyOfAbstractBuilding().
>From there, I can extract the namespace and the type of the variable Truitos, but I can only get the data by switching back to the dom element...
My main problem is that I cant get do that :
Truitos test = dynamic_cast<Truitos>( building-> GenericApplicationPropertyOfAbstractBuilding().at(0) );
(or even replace Truitos by xml_schema::integer)
Regards,
Nicolas
-----Message d'origine-----
De : Boris Kolpackov [mailto:boris at codesynthesis.com]
Envoyé : mercredi 29 novembre 2017 09:31
À : FLACHET Nicolas
Cc : xsd-users at codesynthesis.com
Objet : Re: [xsd-users] Problem with substition groups
FLACHET Nicolas <Nicolas.FLACHET at cstb.fr> writes:
> The parser works fine as a xml reader/writer, however there is no
> attribute generated with constructor and getter/setter for this
> element, so if in my code I can't do :
>
> ElementTest anElement = new ElementTest ;
XSD does not generate classes (I assume you meant "class" not "attribute" above) for elements, only for types. So you need to use ElementTest's (potentially dynamic) type in the above code fragment.
It is clear to me that you don't understand how XSD maps XML Schema constructs (types, elements) to C++ constructs (classes, functions). So I would suggest that you read carefully through the getting started guide:
https://codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/
Boris
More information about the xsd-users
mailing list