Click to return to the XML (Extensible Markup Language) home page    
XML Schemas and the DOM     Representing the XML Sche...     XML Schema Developer's Gu...    
Web Workshop  |  XML (Extensible Markup Language)

XML Schemas and Namespaces


Internet Explorer 5 enables XML Schemas to be referenced directly from a namespace declaration. This allows the XML parser to validate the XML against the grammar defined in the schema. It also allows the object model to expose data types and to allow navigation to the schema document through the definition property (see XML Schemas and the DOM).

A namespace declaration can reference a schema by including the URL to the schema document prefaced by the "x-schema:" string. For example, to reference an XML Schema for books from an XML file conforming to this schema, you would write:

<book xmlns="x-schema:http://www.microsoft.com/xml/schema/book.xml">
  <title>Presenting XML</title>
  <author>Richard Light</author>
  <pages>334</pages>
</book>

Here the default namespace refers to the sample book grammar used in the Defining Elements and Attributes section. The namespace URI is prefixed with "x-schema:" to indicate to the XML parser that there is a schema corresponding to this namespace, with the location corresponding to the remainder of the Universal Resource Identifier (URI). The schema will be loaded and the document will be validated.



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.