OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   XML Schema Question: How to indicate an XML document conforms to an XML

[ Lists Home | Date Index | Thread Index ]
  • From: "Roger L. Costello" <costello@mitre.org>
  • To: xml-dev@ic.ac.uk
  • Date: Wed, 29 Dec 1999 07:58:15 -0500

Hi Folks,

Thanks for the pointer to the location in the XML Schema spec where they
discuss how an XML instance document is to reference an XML Schema
(4.3.2).  I have read it over and wish to confirm my understanding.

I would like to first see if I understand the simple case of how to
indicate in an XML document that it conforms to a single XML Schema. 

Example.  Suppose that I create an XML Schema for BookCatalogues 
(called BookCatalogue.xsd):

<?xml version="1.0"?>
<!DOCTYPE schema SYSTEM "xml-schema.dtd">
<schema xmlns="http://www.w3.org/1999/XMLSchema"
        targetNamespace="http://www.somewhere.org/BookCatalogue">
     ...
</schema>

In my XML document I indicate that it conforms to this XML Schema using
the schemaLocation attribute:

<?xml version="1.0"?>
<BookCatalogue 
          xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance"
          xsi:schemaLocation=
              "http://www.somewhere.org/BookCatalogue
              http://www.somewhere.org/BookCatalogue/BookCatalogue.xsd">
    <Book>
        <Title>Illusions The Adventures of a Reluctant Messiah</Title>
        <Author>Richard Bach</Author>
        <Date>1977</Date>
        <ISBN>0-440-34319-4</ISBN>
        <Publisher>Dell Publishing Co.</Publisher>
    </Book>
    ...
</BookCatalogue>

In the BookCatalogue element (the root element) I declare that the
schemaLocation attribute comes from the XML Schema Instance namespace
(xsi).  The value of the schemaLocation attribute is a pair of values -
a namespace and the URI to a schema.  When the XML Parser processes this
XML document it will use the schemaLocation pair of values to determine
the XML Schema that it conforms to.  It will retrieve the schema at the
URI specified in schemaLocation (in this example, BookCatalogue.xsd) and
then it will open up this schema document to confirm that its
targetNamespace value matches the namespace value shown in
schemaLocation.  In this example it does.  Thus, the XML Parser knows
that "All the stuff between <BookCatalogue> and </BookCatalogue>
conforms to the schema defined at this URI with this namespace."

Is this a correct understanding of how to indicate in an XML document
that it conforms to a particular XML Schema?  /Roger


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS