W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2001

Re: Can the schema change the namespace in the instance?

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 04 Jan 2001 10:01:35 +0000
To: Robert Braddock <stormwarden@bigfoot.com>
Cc: xmlschema-dev@w3.org
Message-ID: <f5blmsrk54w.fsf@cogsci.ed.ac.uk>
Robert Braddock <stormwarden@bigfoot.com> writes:

> I've poked at this a bit and not come up with an answer: I can't seem to
> specify a namespace to be included from a separate schema so it can be used
> in my instance document without explicit namespace commands. That is, I
> expect to be able to do something like this:
>      <schema targetNamespace='ns-A' xmlns:nsb='ns-B'>
>      <element name='doc'>
>        <complexType>
>          <sequence>
>            <element ref='nsb:other-stuff'/>
>          </sequence>
>        </complexType>
>      </element>
>      </schema>
>      <schema targetNamespace='ns-B'>
>        <element name='other-stuff'>
>          <complexType>
>            <sequence>
>              <any namespace='ns-B' minOccurs='0' maxOccurs='unbounded'/>
>            </sequence>
>          <attribute name='xmlns' use='fixed' 
>                     value='ns-B'/>
>          </complexType>
>        </element>
>      </schema>
> and have my instance doc look like this:
>      <doc xmlns='ns-A'>
>      <other-stuff><para>use ns-B tags here, like para</para></other-stuff>
>      <doc>
> but when I try it with XSV it complains about all the other-stuff content
> being undefined in ns-A. It works if I put the xmlns='ns-B' declarations in
> the instance doc explicitly.

You can't do it the way you're trying to.  XML Schema sticks with the
position that NS declarations are not attributes, and in any case does 
not allow NS declarations to be declared as attributes, see [1].  XSV
doesn't check this yet, so you're not getting the error message you should.

I'm trying to use schemas without having to
> incur too much cruft, like explicitly qualifying everything and having to
> have a bunch of redundant namespace declarations. Surely this is not an
> unusual expectation, right? 

Local element declarations can give you the effect you're seeking, see 
the Primer [2].

> (Oh, and are there any instructions for getting XSV running locally on unix?
>  I've gotten it to validate, but I had to change a file to the "forceDTD"
>  branch to get it to work, and I don't see anything that says what that
>  means or whether other files need to be branched and updated too.)

See the XSV status page [3] for information about which branches are
current for which files.


[1] http://www.w3.org/TR/xmlschema-1/#no-xmlns
[2] http://www.w3.org/TR/xmlschema-0/#NS
[3] http://www.ltg.ed.ac.uk/~ht/xsv-status.html
  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 Thursday, 4 January 2001 05:01:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:49 UTC