[xsd-users] Sample code for GML creation?

Boris Kolpackov boris at codesynthesis.com
Fri Jul 30 10:20:52 EDT 2010


Hi Pavel,

Pavel Pohanka <pavelpgt at gmail.com> writes:

> Why the following code generates <gml:featureMember/> element instead of
> <cityObjectMember/> element (which I want to get) within <CityModel>
> element?

This has to do with how XML Schema polymorphism is implemented in
the generated code. Both featureMember and cityObjectMember elements
are of the same type (FeaturePropertyType) and belong to the same 
substitution group. When the generated code sees that the instance
in the object model is of the FeaturePropertyType type, it looks
for the first substituting element that it can use. This happens to
be featureMember.

The CityGML package from the Wiki includes an object model 
customization (see the xml-schema-custom.* files) that allows you
to work around this problem. The idea is to provide a "hint" to
the generate code where the default element choice is not what's
desired. Here is how to use it:

> CityModelType city_model;
> FeaturePropertyType city_object_member;

city_object_member._name ("cityObjectMember")
city_object_member._namespace ("http://www.opengis.net/citygml/1.0");

Boris



More information about the xsd-users mailing list