[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: Multiple xsd:imports on the same namespace
Hi David, > We have been asked to work with some schemas where the definition of > a namespace is split between several schema documents, each defining > a subset of the namespace. An example of what I mean is: > > schemaA.xsd defines namespaceA, and imports both schemaB.xsd and > schemaC.xsd into namespaceB. It then defines an element of each of the > types defined in schemas B and C, in namespaceB. > [snip] > What do people here think? Can anyone suggest a way of validating > documents against these schemas? The general arrangement that you should aim for when using W3C XML Schema is for each namespace to be defined through a single schema document and its includes -- i.e. have a single entry point for the schema information about a particular namespace. In your case, you could create a single entry point by having a fourth schema document (schemaD.xsd) which includes both schemaB and schemaC: <xsd:schema targetNamespace='http://www.example.com/namespaceB' xmlns='http://www.example.com/namespaceB' xmlns:xsd='http://www.w3.org/2001/XMLSchema'> <xsd:include schemaLocation="schemaB.xsd" /> <xsd:include schemaLocation="schemaC.xsd" /> </xsd:schema> Then, rather than importing both schemaB and schemaC into schemaA, just import schemaD instead: <xsd:schema elementFormDefault='qualified' attributeFormDefault='unqualified' targetNamespace='http://www.example.com/namespaceA' xmlns='http://www.example.com/namespaceA' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:nsB='http://www.example.com/namespaceB'> <xsd:import namespace='http://www.example.com/namespaceB' schemaLocation='schemaD.xsd' /> <xsd:element name='Top'> <xsd:complexType> <xsd:sequence> <xsd:element name='B' type='nsB:TypeB' /> <xsd:element name='C' type='nsB:TypeC' /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> and things should work fine. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|