<?
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
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>