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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Associating an XML Schema with a XML Document

[ Lists Home | Date Index | Thread Index ]
  • To: "'List - XML-Dev'" <xml-dev@lists.xml.org>
  • Subject: Re: [xml-dev] Associating an XML Schema with a XML Document
  • From: "Luciano Resende (Discussion List)" <llistas@terra.com.br>
  • Date: Fri, 31 Oct 2003 21:42:37 -0500
  • Cc: <llistas@terra.com.br>
  • References: <000901c39ea2$e9dd9790$6901a8c0@bedford.progress.com>

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: [xml-dev] 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
 
 
assuming no targetNamespace is used you should remove it
 
After
 
Ivan
-----Original Message-----
From: Luciano Resende (Discussion List) [mailto:llistas@terra.com.br]
Sent: Wednesday, October 29, 2003 11:15 PM
To: List - XML-Dev
Subject: [xml-dev] 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>
 




 

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

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