[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

  • From: "Roger L. Costello" <costello@m...>
  • To: xml-dev@i...
  • Date: Wed, 29 Dec 1999 07:58:15 -0500

schemalocation
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@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@i... the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.