- From: Priscilla Walmsley <priscilla@walmsley.com>
- Date: Thu, 18 Apr 2002 08:18:06 -0400
- To: "'saju'" <saju@intercept-india.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hello,
You've got two problems. You are missing two quotes in the instance, one
after the instance namespace and one at the beginning of the
noNamespaceSchemaLocationAttribute value. It should look like:
<cd1 serial="20" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="cd1.xsd" >
Also, your first schema uses the instance namespace instead of the XML
Schema namespace. It should look like:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" >
After I changed these things I was able to validate it against your first
schema using Xerces-J 2.0.1. It gave me the correct error message about
find two "last" elements.
Hope that helps!
Priscilla
------------------------------------------------------------------------
-----
Priscilla Walmsley priscilla@walmsley.com
Author, Definitive XML Schema (Prentice Hall PTR)
------------------------------------------------------------------------
-----
-----Original Message-----
From: saju [SMTP:saju@intercept-india.com]
Sent: Wednesday, April 17, 2002 10:12 AM
To: xmlschema-dev@w3.org
Subject: Re: validation problem with xerces 2
i am using xerces 2 parser. i am able to walk throught the xml .but
unfortunatly the validation is not been done properly .
here with i am senting the xsd and xml file i am trying to validate .
here in this xsd files i have sent the bound of last name as one .so if
this last name tag appears more than once in the xml the parser has to
through error . but unfortunatly i am not getting any error . i would
like
to know y is it happening .
===================================================
XML FILE (cd1.xml)
===================================================
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE cd1>
<cd1 serial="20" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
xsi:noNamespaceSchemaLocation=cd1.xsd" >
<!--
"xsi:schemaLocation=file:///c:/next/cd1.xsd"
-->
<artist type="main">
<name>
<first>Lata</first>
<last>Mangeshkar1</last>
<last>Mangeshkar1</last>
<age dob="1942">60</age>
<sex type="34" height="12" />
</name>
<name>
<first>Lata1</first>
<last>Mangeshkar1</last>
<age dob="1942">601</age>
<sex type="34" height="12" />
</name>
</artist>
</cd1>
XSD user can use either of the XSD files
===============================
====================================================
XSD file (complex type declarations) cd1.xsd
===================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
elementFormDefault="qualified" >
<xsd:annotation>
<xsd:documentation xml:lang="en">CD XML Example Just for Fun
</xsd:documentation>
</xsd:annotation>
<xsd:element name="cd1" type="GenType"/>
<xsd:complexType name="GenType">
<xsd:sequence>
<xsd:element name="artist" type="ArtistType" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="serial" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="ArtistType">
<xsd:sequence>
<xsd:element name="name" type="NameType" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="type" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="NameType">
<xsd:sequence>
<xsd:element name="first" type="xsd:string" minOccurs="0"
maxOccurs="1"/>
<xsd:element name="last" type="xsd:string" minOccurs="0"
maxOccurs="1"/>
<xsd:element name="age">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="dob" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="sex">
<xsd:complexType>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="height" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
=================================================
same XSD ( written simpler way ) cd1.xsd
=================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="cd1">
<xs:complexType>
<xs:sequence>
<xs:element name="artist" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="first" type="xs:string" minOccurs="1"
maxOccurs="1"/>
<xs:element name="last" type="xs:string" minOccurs="1"
maxOccurs="1"/>
<xs:element name="age" type="xs:string" minOccurs="1"
maxOccurs="1"/>
<xs:element name="sex"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
thks in advance
Regards,
saju kanakazhi kandarhi
software engineer
intercept technologies
chennai-18
ph: +91-44-495,8978,9305,8914,0104
cell: +91-9840215889
Received on Thursday, 18 April 2002 08:15:36 UTC