all groups > dotnet xml > october 2003 >
You're in the

dotnet xml

group:

Newbie XSD namespace question



Newbie XSD namespace question Darren S
10/28/2003 10:29:47 PM
dotnet xml: Hi all,

I have the following XML file:

<Config>
<MyFoo xmlns=3D"http://MyCompany/Foo">
</MyFoo>
<MyBar xmlns=3D"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=20
XSD schema files being generated.=20

(Question):=20
Is there a way to just generate a single XSD file to=20
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=3D"1.0" encoding=3D"utf-8"?>
<xs:schema id=3D"NewDataSet" xmlns=3D"" =
xmlns:xs=3D"http://www.w3.org/2001/XMLSchema" =
xmlns:msdata=3D"urn:schemas-microsoft-com:xml-msdata" =
xmlns:app1=3D"http://MyCompany/Foo" xmlns:app2=3D"http://MyCompany/Bar">
<xs:import namespace=3D"http://MyCompany/Foo" =
schemaLocation=3D"Test_app1.xsd" />
<xs:import namespace=3D"http://MyCompany/Bar" =
schemaLocation=3D"Test_app2.xsd" />
<xs:element name=3D"Config">
<xs:complexType>
<xs:sequence>
<xs:element ref=3D"app1:MyFoo" minOccurs=3D"0" />
<xs:element ref=3D"app2:MyBar" minOccurs=3D"0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name=3D"NewDataSet" msdata:IsDataSet=3D"true">
<xs:complexType>
<xs:choice maxOccurs=3D"unbounded">
<xs:element ref=3D"Config" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Test_app1.xsd
-----------------

<?xml version=3D"1.0" standalone=3D"yes"?>
<xs:schema id=3D"NewDataSet" targetNamespace=3D"http://MyCompany/Foo" =
xmlns:mstns=3D"http://MyCompany/Foo" xmlns=3D"http://MyCompany/Foo" =
xmlns:xs=3D"http://www.w3.org/2001/XMLSchema" =
xmlns:msdata=3D"urn:schemas-microsoft-com:xml-msdata" =
attributeFormDefault=3D"qualified" elementFormDefault=3D"qualified" =
xmlns:app1=3D"http://MyCompany/Foo" xmlns:app2=3D"http://MyCompany/Bar">
<xs:import namespace=3D"http://MyCompany/Bar" =
schemaLocation=3D"Test_app2.xsd" />
<xs:element name=3D"MyFoo" type=3D"xs:string" />
</xs:schema>


Test_app2.xsd
---------------
<?xml version=3D"1.0" standalone=3D"yes"?>
<xs:schema id=3D"NewDataSet" targetNamespace=3D"http://MyCompany/Bar" =
xmlns:mstns=3D"http://MyCompany/Bar" xmlns=3D"http://MyCompany/Bar" =
xmlns:xs=3D"http://www.w3.org/2001/XMLSchema" =
xmlns:msdata=3D"urn:schemas-microsoft-com:xml-msdata" =
attributeFormDefault=3D"qualified" elementFormDefault=3D"qualified" =
xmlns:app2=3D"http://MyCompany/Bar" xmlns:app1=3D"http://MyCompany/Foo">
<xs:import namespace=3D"http://MyCompany/Foo" =
schemaLocation=3D"Test_app1.xsd" />
<xs:element name=3D"MyBar" type=3D"xs:string" />
</xs:schema>

Thanks
Re: Newbie XSD namespace question Oleg Tkachenko
10/29/2003 2:56:05 PM
[quoted text, click to view]
Nope. Each XSD file always defines single namespace.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
AddThis Social Bookmark Button