[xsd-users] Compiling GML/CityGML (was: First question)

Boris Kolpackov boris at codesynthesis.com
Mon Feb 9 06:56:22 EST 2009


Jaume,

In the future, please use more descriptive subject lines. The generic
"First question" subject does not give any idea what the email is about.

jaume.faus at vianova.no <jaume.faus at vianova.no> writes:

> I've recently received the assignment of writing a GML (
> http://www.opengeospatial.org/standards/gml) parser in C++ to import data 
> from such file formats. As GML is XML I thought to find a tool that, like 
> this one, generates the parser from the schemas. It is a good thing becaus 
> GML is huge. It consts of 30 xsd files.

Since you are trying to use CityGML, I assume you refer to GML 3.1.1
which is the version required by CityGML 1.0:

http://schemas.opengis.net/gml/3.1.1/

http://schemas.opengis.net/citygml/


> I have downloaded all the xsd defining this standard into a file structure 
> that emulates the one existing in http://schemas.opengis.net/gml/
> 
> but when I run the command
> 
> xsdcxx parse schemafile
> 
> I get several errors telling that AbstractFeature has been implicitly 
> declared as anyType. Well, AbstractFeature is the base class in GML so I 
> suspect that this anyType is made on purpose to make me map it into my 
> app's base class. Is that right? How should I deal with it? should I edit 
> the gml.xsd to make AbstractFeature be of my app's type? If so, how do I 
> make it?

The diagnostics you get about AbstractFeature being implicitly of
anyType are warnings, not errors. There is a page on the Wiki for
GML which provides more information on how to compile this schema.
I suggest that you download the "single directory" package mentioned
on that page:

http://wiki.codesynthesis.com/Schemas/GML

Also, GML is a fairly complex schema so I suggest that you start with
the C++/Tree mapping because it is easier to use. Since this schema uses
polymorphism, you will probably want to read Section 2.11, "Mapping for
xsi:type and Substitution Groups" in the C++/Tree Mapping User Manual:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.11


> In other way, I tried to make a CityGML parser which is a profile (more or 
> less a subset with some specific additions) of GML, therefore its xsd are 
> continuously referencing to GML ones. As I have all xsd in my harddrive in 
> the same file structure I thought it will automatically find the resources 
> in order to compile. But references in CityGML's schemas are made via http 
> links (http://schemas.opengis/gml/...) and it seems that xsdcxx doesn't 
> recognize them and tries to open this string as a file.

There is a test available for CityGML 1.0:

http://www.codesynthesis.com/~boris/tmp/citygml-test.tar.gz

It contains the GML 3.1.1 and CityGML 1.0 schemas as well as a test driver
and makefile. There is also the README file inside with more information.
Note, that since you are using the "official" Debian package for XSD, you
will need to change "XSD := xsd" to "XSD := xsdcxx" in the makefile.


> Is it possible to configure xsdcxx to automatically download the xsd 
> files needed instead of having to download them manually and, in this 
> case, edit them to make its links to point to files in the filesystem 
> instead of internet addresses?

XSD does not support remote schema retrieval so you will need to download
the local copies of the schemas you are compiling. You, however, don't
need to modify them. Instead, you can use the --location-map  option to
re-map include/import locations. See the citygml.options file in the
above test for an example.

Boris




More information about the xsd-users mailing list