- From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
- Date: 23 Oct 2000 17:09:47 +0100
- To: "Lin, QingFeng (William)" <QingFeng_Lin@jdedwards.com>
- Cc: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>, "Kashanian, Kamran" <Kamran_Kashanian@jdedwards.com>
[please don't send schema questions to xml-uri@w3.org] "Lin, QingFeng (William)" <QingFeng_Lin@jdedwards.com> writes: > Does anybody know how to write a schema for an XML document with > multiple namespace? > > For example. > File:test.xml > <?xml version="1.0" ?> > <test xmlns="http://test" > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" > xsi:schemaLocation="http://test test.xsd"> > <ns1:a xmlns:ns1="http://test/ns1">this is a</ns1:a> > <ns2:b xmlns:ns2="http://test/ns2">this is b</ns2:b> > </test> > One way I have tried is as following: > file:test.xsd > <?xml version="1.0"?> > <schema xmlns="http://www.w3.org/1999/XMLSchema" > targetNamespace="http://test" xmlns:ns0="http://test" > xmlns:ns2="http://test/ns2" xmlns:ns1="http://test/ns1"> > <element name="test" type="ns0:testType"/> > <import namespace="http://test/ns1" schemaLocation="a.xsd"/> > <import namespace="http://test/ns2" schemaLocation="b.xsd"/> > <complexType name="testType" content="elementOnly"> > <element name="a" ref="ns1:aType"/> > <element name="b" ref="ns2:bType"/> > </complexType> > </schema> This is close, but since 'a' and 'b' are here declared in ns0, your instance should read <a... <b... Also, you've used ref= where you should have used type= twice above. With those changes, and large numbers of namespace fixes, your example validates with XSV [1]. ht http://www.w3.org/2000/09/webdata/xsv -- 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 Monday, 23 October 2000 12:10:09 UTC