TR: [xsd-users] Problem with substition groups

FLACHET Nicolas Nicolas.FLACHET at cstb.fr
Thu Dec 7 05:56:46 EST 2017


Hello,

I used the polymorphic attribute tricks and it works for the most part :
* I can read and write a cityGML file with the poymorphic elements.
* I can ad an element to the building sequence and it's correcly writed on the deserialization.

However, I don't know how to read back an element.

Here's an exemple for "Truitos":

core::AbstractCityObjectType::_GenericApplicationPropertyOfCityObject_sequence gapSequence;
ade::poly_Truitost aTruitos(10);
gapSequence.push_back(aTruitos);

And to read it back : 
for (int i = 0; i < b->_ gapSequence ().size(); ++i)
{
   ade::poly_Truitost  *test = dynamic_cast< ade::poly_Truitost *>(& gapSequence .at(i) );
}

However, test is always null. 

Best Regards,
Nicolas

-----Message d'origine-----
De : xsd-users-bounces at codesynthesis.com [mailto:xsd-users-bounces at codesynthesis.com] De la part de FLACHET Nicolas
Envoyé : mercredi 6 décembre 2017 10:03
À : xsd-users at codesynthesis.com
Objet : RE: TR: [xsd-users] Problem with substition groups

Thanks Boris, that could do the trick I'll try it on the large schema database !

> I don't see this element (Truitos) defines in any of them. So this must be coming from another schema and this explains why nobody else using GML/CityGML had the same issue.

xsd generate cityGML quite nicely, but our main problem now is with ADE (domain extension) that add polymorphic attribute to multi-polymorphic classes. "truitos" is an attribute for our own ADE, but we find the same problem with the energy ADE for exemple.

http://www.citygmlwiki.org/index.php/CityGML_Energy_ADE

with, for exemple, the attributes : 
 <element name="buildingType" type="gml:CodeType" substitutionGroup="bldg:_GenericApplicationPropertyOfAbstractBuilding"/>
<element name="isLandmarked" type="boolean" substitutionGroup="bldg:_GenericApplicationPropertyOfAbstractBuilding"/>

Still, this ADE is on alpha or beta state, and I have no problem with the noise ADE.


-----Message d'origine-----
De : Boris Kolpackov [mailto:boris at codesynthesis.com] Envoyé : mardi 5 décembre 2017 10:11 À : FLACHET Nicolas Cc : xsd-users at codesynthesis.com Objet : Re: TR: [xsd-users] Problem with substition groups

FLACHET Nicolas <Nicolas.FLACHET at cstb.fr> writes:

> <xs:element name="_GenericApplicationPropertyOfAbstractBuilding" 
> type="xs:anyType" abstract="true"/>
>
> <xs:element name="Truitos" type="integer" 
> substitutionGroup="_GenericApplicationPropertyOfAbstractBuilding"/>

Ok, I've refreshed my memory and C++/Tree does not support polymorphism for XML Schema types that are mapped to fundamental C++ types.

So in the above example type integer (shouldn't it be xs:integer?) is the problem. I've also looked into GML/CityGML schemas and I don't see this element (Truitos) defines in any of them. So this must be coming from another schema and this explains why nobody else using GML/CityGML had the same issue.

The easiest workaround would be to tweak the schema to use a type derived from xs:integer. For example:

<xs:simpleType name="poly_integer">
  <xs:restriction base="xs:integer"/>
</xs:simpleType>

<xs:element name="Truitos" type="poly_integer" substitutionGroup="_GenericApplicationPropertyOfAbstractBuilding"/>

Boris




More information about the xsd-users mailing list