[xsd-users] compiling schemas with imports

Boris Kolpackov boris at codesynthesis.com
Fri Nov 5 10:48:09 EDT 2010


Hi Lorenzo,

Lorenzo Seidenari <sixmoney at gmail.com> writes:

> >xsdcxx cxx-tree onvif.xsd
> onvif.xsd: error: 'http://www.w3.org/2005/05/xmlmime': unable to open in
> read mode
>
> [...] 
>
> Is there a way to directly compile a schema with import without compiling
> the imports separately?

There are two separate questions here. The first is whether it is possible
to compile a schema that is a remote resource (HTTP). The answer is no.
The XSD compiler does not support network access for various reasons. So
you will need to download each imported schema to the disk. Then you can
either modify the importing schema to reference the local files or you can
use the --location-map option to re-map schema locations without modifying
the schema, for example:

--location-map http://www.w3.org/2005/05/xmlmime=xmlmime.xsd

The second question is whether it is possible to compile just the root
schema without having to also compile all the included/imported schemas.
The answer is yes. You can use the file-per-type mode to achieve this.
Note, however, that it is more manageable to compile schemas using the
default file-per-schema mode since the number of files generated in the
file-per-type mode can be quite large. Plus, if all your schemas are in
the same directory, you can compile them all in one go:

xsdcxx cxx-tree *.xsd

Boris



More information about the xsd-users mailing list