Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / October 2003

Tip: Looking for answers? Try searching our database.

Newbie XSD namespace question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Darren S - 28 Oct 2003 17:59 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.