W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > July to September 2000

Re: importing elements from multiple namespaces and defining their sc hemaLocations in a corresponding XML data file

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 29 Sep 2000 09:51:23 +0100
To: chuck.han@autodesk.com
Cc: www-xml-schema-comments@w3.org
Message-ID: <f5bg0mj60ok.fsf@cogsci.ed.ac.uk>
chuck.han@autodesk.com writes:

> Let's say I have a complexType "twoExamplesType" made up of two elements named
> "example" from different namespaces and a global element "twoExamples" that uses this
> complexType:
> 
>  
> 
>     <xsd:element name="twoExamples" type="twoExamplesType"/>
> 
>     <xsd:complexType name="twoExamplesType">
> 
>         <xsd:element ref="ns1:example"/>
> 
>         <xsd:element ref="ns2:example"/>
> 
>     </xsd:complexType>
> 
>  
> 
> How do I use "twoExamples" in an XML data file and give the schemaLocation of
> "twoExamples" and the two "example" elements?  I assume that this structure is
> partially correct...
> 
>  
> 
>     <twoExamples xmlns="http://www.example.com" xmlns:ns1="http://www.example.com/ns1"
> xmlns:ns2="http://www.example.com/ns2">
> 
>         <ns1:example/>
> 
>         <ns2:example/>
> 
>     </twoExamples>
> 
>  
> 
> ...but I am not clear how to define the schemaLocation for all three
> namespaces.

That's all fine (note you do need
  xmlns:ns1="http://www.example.com/ns1"
  xmlns:ns2="http://www.example.com/ns2"
and
  <import namespace="http://www.example.com/ns1"/>
  <import namespace="http://www.example.com/ns2"/>
in your schema)

Wrt your instance, assuming twoExamples is the doc't element, you need

<twoExamples
         xmlns="http://www.example.com"
         xmlns:ns1="http://www.example.com/ns1"
         xmlns:ns2="http://www.example.com/ns2"
         xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
         xsi:schemaLocation="http://www.example.com [URL1]
                             http://www.example.com/ns1 [URL2]
                             http://www.example.com/ns2 [URL3]">

        <ns1:example/>

        <ns2:example/>

</twoExamples>

where obviously I don't know what to put for URL{1,2,3}.

Hope this helps

N.B.  www.foo.com actually exists, but IANA reserves www.example.com,
so it's a better choice for examples such as this.
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/
Received on Friday, 29 September 2000 04:51:34 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:49:53 UTC