[xsd-users] parser xsd file recursively

Boris Kolpackov boris at codesynthesis.com
Wed Apr 25 11:31:52 EDT 2012


Xiaoxing,

Li, Xiaoxing (GE Global Research) <lixia at ge.com> writes:

> I am trying to use xsd 3.3.0 to generate c++ mapping for a set of .xsd
> files defined recursively. I.e, I have a "all.xsd", where a bunch of
> other xsd files are included as
>
> <xs:include schemaLocation="SomeXMLSchema.xsd"/>.
> 
> I tried to use
> 
> ]$ ..bin/xsd cxx-parser --xml-parser expat all.xsd,
> 
> but the c++ mappings are not generated for all the included files. I am
> wondering if there is a way of parsing all the xsd files recursively
> using xsd 3.3.0.

By default, XSD requires that you compile each included/imported schema
separately. If all your schemas are in the same directory, then you can
do it like this:

$ .../bin/xsd cxx-parser --xml-parser expat *.xsd

There is also the file-per-type mode (activated with the --file-per-type
option) which will generate code for all the included/imported schemas in
one go. But it will also generate  a separate set of C++ files for each
schema type. You read more about this mode in this reply to a similar
question:

http://www.codesynthesis.com/pipermail/xsd-users/2012-April/003613.html

Boris



More information about the xsd-users mailing list