Hi all,
I have the following XML file:
<Config>
<MyFoo xmlns="http://MyCompany/Foo">
</MyFoo>
<MyBar xmlns="http://MyCompany/Bar">
</MyBar>
</Config>
For a project specific reason, I need to keep <MyFoo> and <MyBar>
in 2 seperate namespaces.
I run XSD.exe to generate my schema. This results in the following 3
XSD schema files being generated.
(Question):
Is there a way to just generate a single XSD file to
include all the information. (i.e) Can Test.xsd include the definitions
in Test_app1.xsd and Test_app2.xsd, such that I only need to
ship a single XSD file, Any pointers would be of help ?
Test.xsd
--------
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:app1="http://MyCompany/Foo" xmlns:app2="http://MyCompany/Bar">
<xs:import namespace="http://MyCompany/Foo" schemaLocation="Test_app1.xsd" />
<xs:import namespace="http://MyCompany/Bar" schemaLocation="Test_app2.xsd" />
<xs:element name="Config">
<xs:complexType>
<xs:sequence>
<xs:element ref="app1:MyFoo" minOccurs="0" />
<xs:element ref="app2:MyBar" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="Config" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Test_app1.xsd
-----------------
<?xml version="1.0" standalone="yes"?>
<xs:schema id="NewDataSet" targetNamespace="http://MyCompany/Foo" xmlns:mstns="http://MyCompany/Foo" xmlns="http://MyCompany/Foo" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:app1="http://MyCompany/Foo" xmlns:app2="http://MyCompany/Bar">
<xs:import namespace="http://MyCompany/Bar" schemaLocation="Test_app2.xsd" />
<xs:element name="MyFoo" type="xs:string" />
</xs:schema>
Test_app2.xsd
---------------
<?xml version="1.0" standalone="yes"?>
<xs:schema id="NewDataSet" targetNamespace="http://MyCompany/Bar" xmlns:mstns="http://MyCompany/Bar" xmlns="http://MyCompany/Bar" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:app2="http://MyCompany/Bar" xmlns:app1="http://MyCompany/Foo">
<xs:import namespace="http://MyCompany/Foo" schemaLocation="Test_app1.xsd" />
<xs:element name="MyBar" type="xs:string" />
</xs:schema>
Thanks
Darren
Oleg Tkachenko - 29 Oct 2003 13:56 GMT
> For a project specific reason, I need to keep <MyFoo> and <MyBar>
> in 2 seperate namespaces.
[quoted text clipped - 5 lines]
> Is there a way to just generate a single XSD file to
> include all the information.
Nope. Each XSD file always defines single namespace.

Signature
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel