W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2007

Re: multiple namespaces

From: <noah_mendelsohn@us.ibm.com>
Date: Mon, 23 Apr 2007 10:35:58 -0400
To: "Andrew Welch" <andrew.j.welch@gmail.com>
Cc: xmlschema-dev@w3.org
Message-ID: <OF017E23A2.E672105F-ON852572C6.004FA067-852572C6.00503B78@lotus.com>

Andrew Welch writes:

> With this XML:
>   <ns1:foo>some text</ns1:foo>
>   <ns2:bar>some text</ns2:bar>

Well, first of all, that's not an XML document you could validate, so 
let's assume you meant something along the lines of:

With this XML:

  <ns1:root xmlns:ns1="uri1" xmlns:ns1="uri2">
    <ns1:foo>some text</ns1:foo>
    <ns2:bar>some text</ns2:bar>

> Am I right in thinking I need two schemas - one for each namespace?

Well, you're terminology isn't quite what the Recommendation uses, but in 
the sense you probably mean the answer is "yes", at least presuming you 
wanted to actually validate the contents of both elements, rather than 
just accepting them with a wildcard.  To be a bit more precise, to 
validate the element information item "root" you would need a single 
>schema< with components declaring (at least) the three elements ns1:root, 
ns1:foo, and ns2:bar.

What you're (almost surely) thinking of as a schema is what the 
Recommendation calls a >Schema Document<, I.e. an XML document with a root 
of <xs:schema>.  Since each of those can contribute declarations for at 
most one so-called target namespace, in this case ns1 or ns2, you will 
need two such documents.  Very probably the schema document for ns1 will 
import the one for ns2, though there are other ways to get both documents 
used.  For example, some processors would let you name both schema 
documents on a command line or in an api. 

Anyway, the careful answer your question is:  you will be using one 
schema, which will almost surely be built (composed) from at least two 
schema documents.  The informal answer to your question is:  yes.  :-)


Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
Received on Monday, 23 April 2007 14:36:22 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:12 UTC