[xsd-users] Re: [xsde-users] how to handle xsd:include?

Boris Kolpackov boris at codesynthesis.com
Wed Feb 13 14:46:30 EST 2008


Hi Gennady,

You have sent your questions to the wrong mailing list again. Please
send questions about CodeSynthesis XSD to the xsd-users at codesynthesis.com
mailing list, not to xsde-users.

Gennady Khokhorin <gok at aerometric-ak.com> writes:

> Have a complex metadata xsd with include statement:
>
> main.xsd:
> <xsd:include schemaLocation="sect01.xsd"/>
>
> XSD.exe generated classes for main.xsd fine and in .hxx it includes
> additional schemas like that:
> #include "sect01.hxx"
>
> As I'm guessing I have run now XSD.exe on sect01.xsd but got an errors
> about types declared in main.xsd:
> Unknown base type myType for type <...>
> where myType declared in main.xsd like that:
>
> main.xsd:
> <xsd:simpleType name="myType">
> 	<xsd:restriction base="xsd:string">
> 		<xsd:pattern value="\s*\S(.|\n|\r)*"/>
> 	</xsd:restriction>
> </xsd:simpleType>
>
> Does somebody knows how to handle included xsd and global types in
> XSD.exe?

It appears that your sect01.xsd does not include/import all the
type definitions that it uses and as a result it is not valid by
itself. You have two options:

1. Fix sect01.xsd to include all the necessary schemas so that
   it becomes self-sufficient.

2. Use the file-per-type compilation mode that was introduced
   in XSD 3.1.0. In this mode the compiler will generate a
   set of source files for each XML Schema type. To use this
   mode you will invoke the compiler like so:

   xsd.exe cxx-tree --file-per-type main.xsd

   Note that in this mode you won't need to compile sect01.xsd
   or any other schema that main.xsd may import or include
   separately.

   For more information about the file-per-type mode, please
   see the following blog post:

   http://www.codesynthesis.com/~boris/blog/2008/02/13/codesynthesis-xsd-3-1-0-released/

Boris




More information about the xsd-users mailing list