- From: Martin Gudgin <marting@develop.com>
- Date: Fri, 29 Sep 2000 08:44:48 +0100
- To: "Schema Comments" <www-xml-schema-comments@w3.org>
Hi Chuck, You would do it like this; <twoFoos xmlns='http://www.foo.com' xmlns:ns1='http://www.foo.com/ns1' xmlns:ns2='http://www.foo.com/ns2' xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance' xsi:schemaLocation='http://www.foo.com http://www.foo.com/foo.xsd http://www.foo.com/ns1 http://www.foo.com/ns1.xsd http://www.foo.com/ns2 http://www.foo.com/ns2.xsd' > <ns1:foo/> <ns2:foo/> </twoFoos> It would also be legal to do this; <twoFoos xmlns='http://www.foo.com' xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance' xsi:schemaLocation='http://www.foo.com http://www.foo.com/foo.xsd' > <ns1:foo xmlns:ns1='http://www.foo.com/ns1' xsi:schemaLocation='http://www.foo.com/ns1 http://www.foo.com/ns1.xsd' /> <ns2:foo xmlns:ns2='http://www.foo.com/ns2' xsi:schemaLocation='http://www.foo.com/ns2 http://www.foo.com/ns2.xsd' /> </twoFoos> Other combinations with respect to placement of namespace declarations and xsi:schemaLocation attributes are also possible. Note that as per[1] bullet 4, the schemaLocation for a particular nsuri must *not* appear after the first occurence of an element or attribute in that namespace. So the following would be illegal; <twoFoos xmlns='http://www.foo.com' xmlns:ns1='http://www.foo.com/ns1' xmlns:ns2='http://www.foo.com/ns2' xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance' > <ns1:foo/> <ns2:foo xsi:schemaLocation='http://www.foo.com http://www.foo.com/foo.xsd http://www.foo.com/ns1 http://www.foo.com/ns1.xsd http://www.foo.com/ns2 http://www.foo.com/ns2.xsd' /> </twoFoos> because the schemeLocations for http://www.foo.com and http://www.foo.com/ns1 appear after the first occurence of elements in those namespaces. Hope this helps, Martin Gudgin [1] http://www.w3.org/TR/xmlschema-1/#schema-loc ----- Original Message ----- From: <chuck.han@autodesk.com> To: <www-xml-schema-comments@w3.org> Sent: Thursday, September 28, 2000 11:14 PM Subject: importing elements from multiple namespaces and defining their sc hemaLocations in a corresponding XML data file > Let's say I have a complexType "twoFoosType" made up of two elements > named "foo" from different namespaces and a global element "twoFoos" > that uses this complexType: > > <xsd:element name="twoFoos" type="twoFoosType"/> > <xsd:complexType name="twoFoosType"> > <xsd:element ref="ns1:foo"/> > <xsd:element ref="ns2:foo"/> > </xsd:complexType> > > How do I use "twoFoos" in an XML data file and give the schemaLocation > of "twoFoos" and the two "foo" elements? I assume that this structure > is partially correct... > > <twoFoos xmlns="http://www.foo.com" > xmlns:ns1="http://www.foo.com/ns1" xmlns:ns2="http://www.foo.com/ns2"> > <ns1:foo/> > <ns2:foo/> > </twoFoos> > > ...but I am not clear how to define the schemaLocation for all three > namespaces. > > thanks in advance, Chuck > > Chuck Han, Data Architect > Autodesk, Inc. > +1.415.507.8742 > >
Received on Friday, 29 September 2000 03:48:22 UTC