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

Gennady Khokhorin gok at aerometric-ak.com
Fri Feb 15 21:32:12 EST 2008


Hello, Boris.
Did make approach #2 (one file for each type) to compile.
My xsd's considered have a cross-reference like that:

main.xsd (defines global data types, references to element from
sect01.xsd):
----------
<xsd:include schemaLocation="sect01.xsd"/>
<xsd:complexType name="metadataType">
	<xsd:sequence>
		<xsd:element ref="idinfo"/> (this element defined in
sect01.xsd)
	</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="FGDCstring">
..

sect01.xsd (using global data type defined in main.xsd, define element
referenced in main.xsd):
----------
<xsd:element name="idinfo" type="idinfoType"/>
  <xsd:simpleType name="idinfoType">
	<xsd:restriction base="FGDCstring"/>
...

Thanks for your help!
Gennady

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: Friday, February 15, 2008 4:02 AM
To: Gennady Khokhorin
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsde-users] how to handle xsd:include?

Hi Gennady,

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

> Did try both approaches:
> 1. including main.xsd (myType declared here) in 
> sect01.xsd:<xsd:include schemaLocation="main.xsd"/> just before myType

> declaration. main.xsd has the same include:
> <xsd:include schemaLocation="sect01.xsd"/>

>From your description I gather that the dependency between main.xsd and
sect01.xsd involves inheritance. If that's the case then this approach
won't work (in C++ you cannot have two headers including each other with
a type in one header inheriting from a type in the other).

> 2. using --file-per-type option for main.xsd only. This produced 
> double declarations for otherTypes in sect01.hxx and in otherType.hxx

I guess I haven't explained this clear enough. With the --file-per-type
option you *only* compile your root schema (main.xsd). You don't run the
XSD compiler on sect01.xsd in this mode since sect01.hxx will be
automatically generated while you are compiling main.xsd.

Boris




More information about the xsd-users mailing list