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

Re: Associating an XML Schema with a XML Document

  • To: "'List - XML-Dev'" <xml-dev@l...>
  • Subject: Re: Associating an XML Schema with a XML Document
  • From: "Luciano Resende (Discussion List)" <llistas@t...>
  • Date: Fri, 31 Oct 2003 21:42:37 -0500
  • Cc: <llistas@t...>
  • References: <000901c39ea2$e9dd9790$6901a8c0@b...>

schemalocation file
Title: Message
Thank you all for all the help, looks like i got the xml working, at least my xml editor recognize it as a valid xml :
 

<?xml version="1.0" encoding="UTF-8"?>

<books xsi:noNamespaceSchemaLocation="file:///d:/ibm/dev/workspaces/dominoportal/dominoadapter/booksextended.xsd"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

.....

 

I have a sample JAXP/DOM code working with the validation based on a DTD, can somebody give any sample on how to use a parser to validate the xml document using the XML Schema associated with it ?

 

----- Original Message -----

Sent: Thursday, October 30, 2003 12:01 AM
Subject: RE: Associating an XML Schema with a XML Document

 
Luciano,
 
The schema URL doesn't seem correct
 
 
it should be
 
 
The schema you are using doesn't have any targetNamespace so you should use
 
 
your xml document set the default namespace
 
xmlns="http://www.books.org/"
 
assuming no targetNamespace is used you should remove it
 
After
 
Ivan
-----Original Message-----
From: Luciano Resende (Discussion List) [mailto:llistas@t...]
Sent: Wednesday, October 29, 2003 11:15 PM
To: List - XML-Dev
Subject: Associating an XML Schema with a XML Document

I have the following Schema and XML files...
I want to specify that the xml is based on the schema defined as file : booksextended.xsd
Could someone tell me what I'm doing wrong on the xml file ?
 
XML Schema :
 
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="author" type="xsd:string"/>
    <xsd:element name="book">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="author"/>
                <xsd:element ref="title"/>
                <xsd:choice maxOccurs="1" minOccurs="0">
                    <xsd:element ref="publisher"/>
                    <xsd:element ref="supplier"/>
                </xsd:choice>
                <xsd:element ref="price"/>
            </xsd:sequence>
            <xsd:attribute name="isbn" type="xsd:string" use="optional"/>
            <xsd:attribute name="reference" type="xsd:string" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="books">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element maxOccurs="unbounded" minOccurs="1" ref="book"/>
            </xsd:sequence>
            <xsd:attribute name="NewAttribute1" type="xsd:string" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="price">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="onSale" type="xsd:string" use="optional"/>
                    <xsd:attribute name="NewAttribute1"
                        type="xsd:string" use="optional"/>
                    <xsd:attribute name="NewAttribute2"
                        type="xsd:string" use="optional"/>
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="title" type="xsd:string"/>
    <xsd:element name="publisher" type="xsd:string"/>
    <xsd:element name="supplier" type="xsd:string"/>
</xsd:schema>
XML Document
 
<?xml version="1.0" encoding="UTF-8"?>
<books xmlns="http://www.books.org"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="file://d//ibm//dev//workspaces//dominoportal//dominoadapter booksextended.xsd">
 <book reference="1">
  <author>Tom Wolfe</author>
  <title>The Right Stuff</title>
  <price>$6.00</price>
 </book>
 <book>
  <author>R.L. Stevenson</author>
  <title>Treasure Island</title>
  <price>$13.00</price>
 </book>
 <book>
  <author>Carl Hiaasen</author>
  <title>Tourist Season</title>
  <price>$5.99</price>
 </book>
 <book>
  <author>Dave Barry</author>
  <title>Big Trouble</title>
  <price>$3.95</price>
 </book>
</books>
 

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.