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

Re: Using XML Schema in local directory

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 12 Dec 2001 19:20:42 +0000
Message-ID: <10012645563.20011212192042@jenitennison.com>
To: Lau Chung Sing <singlau_lcs@yahoo.com>
CC: xmlschema-dev@w3.org
Hi Carter,

> I would like to ask if I have a XML schema (let say put in
> c:\schema\schema.xsd), can I set the above path in the namespace of
> the XML file I would like to validate and then parse the file?

To link from the instance XML document to the schema document, you
need to use the xsi:schemaLocation or xsi:noNamespaceSchemaLocation
attributes (depending on whether or not your markup language uses a
namespace).  The xsi:* attributes are all in the namespace
http://www.w3.org/2001/XMLSchema-instance.

So your instance document should look like:

<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="file:///C:/schema/schema.xsd">
...
</foo>

Or something like:

<foo xmlns="http://www.example.com/"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.example.com/
                         file:///C:/schema/schema.xsd">
...
</foo>

And if the latter then the xs:schema element in the schema at
schema.xsd should have a targetNamespace attribute equal to
'http://www.example.com/' (the namespace of the foo element).

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 12 December 2001 14:20:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:25 GMT