You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Sam Pullara <sa...@j2soft.com> on 2000/09/28 19:48:26 UTC
Schema Validation
Schema validation doesn't seem to working for me. Here is the code that I
am using to parse the document:
org.apache.xerces.parsers.DOMParser parser = new
org.apache.xerces.parsers.DOMParser();
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://xml.org/sax/features/namespaces", true);
Here is the xml file:
<?xml version="1.0"?>
<dvd xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="dvd.xsd">
<title>Terminator 2: Judgement Day</title>
<year>1991</year>
<genre>Action</genre>
<genre>Sci-Fi</genre>
<genre>Comedy</genre>
<url>
<name>Amazon</name>
<link>http://www.amazon.com/exec/obidos/ASIN/B00004TRD8/o/qid=970113945/sr=8
-12/ref=aps_sr_d_5_1/103-2399305-5195831</link>
</url>
<url>
<name>IMDB</name>
<link>http://us.imdb.com/Details?0103064</link>
</url>
</dvd>
Here is the xsd file:
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2000/10/XMLSchema">
<sequence>
<element name="dvd" type="DVD"/>
</sequence>
<complexType name="DVD">
<simpleType name="integer">
<restriction base="string">
<enumeration value="Sci-Fi"/>
<enumeration value="Action"/>
<enumeration value="Horror"/>
</restriction>
</simpleType>
<complexType name="URL">
<sequence>
<element name="name" type="string"/>
<element name="link" type="string"/>
</sequence>
</complexType>
<sequence>
<element name="title" type="string"/>
<element name="year" type="year"/>
<element name="genre" maxOccurs="unbounded" type="Genre"/>
<element name="url" maxOccurs="unbounded" type="URL"/>
</sequence>
</complexType>
</schema>
I know that it is reading the xsd file but the only thing that will stop it
from parsing is a syntax error in that file. In this example I have a bad
enumeration value but I have tried a bunch of errors and none of them raise
an error.
Sam
Re: Schema Validation
Posted by Eric Ye <er...@locus.apache.org>.
Not yet.
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: "Sam Pullara" <sa...@j2soft.com>
To: <xe...@xml.apache.org>; "Eric Ye" <er...@locus.apache.org>
Sent: Thursday, September 28, 2000 12:02 PM
Subject: RE: Schema Validation
> Thanks for the hint. I should have known they would be non-fatal.
Anyway,
> most of my other questions are problems between the September 22 draft and
> the April 7 draft that xerces implements. Is there a time table for
> September 22 support? Since I was just getting into Schema's I went for
the
> newest specification :)
>
> Thanks, sorry for the newbie question,
> Sam
>
> -----Original Message-----
> From: Eric Ye [mailto:ericye@locus.apache.org]
> Sent: Thursday, September 28, 2000 11:05 AM
> To: xerces-j-dev@xml.apache.org
> Subject: Re: Schema Validation
>
>
> To catch the error messges, you need to implement a ErrorHandler and
> register it on the parser object you created
> _____
>
>
> Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
>
> ----- Original Message -----
> From: "Sam Pullara" <sa...@j2soft.com>
> To: "Xerces-J-Dev" <xe...@xml.apache.org>
> Sent: Thursday, September 28, 2000 10:48 AM
> Subject: Schema Validation
>
>
> > Schema validation doesn't seem to working for me. Here is the code that
I
> > am using to parse the document:
> >
> > org.apache.xerces.parsers.DOMParser parser = new
> > org.apache.xerces.parsers.DOMParser();
> > parser.setFeature("http://xml.org/sax/features/validation", true);
> > parser.setFeature("http://xml.org/sax/features/namespaces", true);
> >
> > Here is the xml file:
> >
> > <?xml version="1.0"?>
> > <dvd xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> > xsi:noNamespaceSchemaLocation="dvd.xsd">
> > <title>Terminator 2: Judgement Day</title>
> > <year>1991</year>
> > <genre>Action</genre>
> > <genre>Sci-Fi</genre>
> > <genre>Comedy</genre>
> > <url>
> > <name>Amazon</name>
> >
> >
>
<link>http://www.amazon.com/exec/obidos/ASIN/B00004TRD8/o/qid=970113945/sr=8
> > -12/ref=aps_sr_d_5_1/103-2399305-5195831</link>
> > </url>
> > <url>
> > <name>IMDB</name>
> > <link>http://us.imdb.com/Details?0103064</link>
> > </url>
> > </dvd>
> >
> > Here is the xsd file:
> >
> > <?xml version="1.0"?>
> > <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
> > <sequence>
> > <element name="dvd" type="DVD"/>
> > </sequence>
> > <complexType name="DVD">
> > <simpleType name="integer">
> > <restriction base="string">
> > <enumeration value="Sci-Fi"/>
> > <enumeration value="Action"/>
> > <enumeration value="Horror"/>
> > </restriction>
> > </simpleType>
> > <complexType name="URL">
> > <sequence>
> > <element name="name" type="string"/>
> > <element name="link" type="string"/>
> > </sequence>
> > </complexType>
> > <sequence>
> > <element name="title" type="string"/>
> > <element name="year" type="year"/>
> > <element name="genre" maxOccurs="unbounded" type="Genre"/>
> > <element name="url" maxOccurs="unbounded" type="URL"/>
> > </sequence>
> > </complexType>
> > </schema>
> >
> > I know that it is reading the xsd file but the only thing that will stop
> it
> > from parsing is a syntax error in that file. In this example I have a
bad
> > enumeration value but I have tried a bunch of errors and none of them
> raise
> > an error.
> >
> > Sam
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>
RE: Schema Validation
Posted by Sam Pullara <sa...@j2soft.com>.
Thanks for the hint. I should have known they would be non-fatal. Anyway,
most of my other questions are problems between the September 22 draft and
the April 7 draft that xerces implements. Is there a time table for
September 22 support? Since I was just getting into Schema's I went for the
newest specification :)
Thanks, sorry for the newbie question,
Sam
-----Original Message-----
From: Eric Ye [mailto:ericye@locus.apache.org]
Sent: Thursday, September 28, 2000 11:05 AM
To: xerces-j-dev@xml.apache.org
Subject: Re: Schema Validation
To catch the error messges, you need to implement a ErrorHandler and
register it on the parser object you created
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: "Sam Pullara" <sa...@j2soft.com>
To: "Xerces-J-Dev" <xe...@xml.apache.org>
Sent: Thursday, September 28, 2000 10:48 AM
Subject: Schema Validation
> Schema validation doesn't seem to working for me. Here is the code that I
> am using to parse the document:
>
> org.apache.xerces.parsers.DOMParser parser = new
> org.apache.xerces.parsers.DOMParser();
> parser.setFeature("http://xml.org/sax/features/validation", true);
> parser.setFeature("http://xml.org/sax/features/namespaces", true);
>
> Here is the xml file:
>
> <?xml version="1.0"?>
> <dvd xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="dvd.xsd">
> <title>Terminator 2: Judgement Day</title>
> <year>1991</year>
> <genre>Action</genre>
> <genre>Sci-Fi</genre>
> <genre>Comedy</genre>
> <url>
> <name>Amazon</name>
>
>
<link>http://www.amazon.com/exec/obidos/ASIN/B00004TRD8/o/qid=970113945/sr=8
> -12/ref=aps_sr_d_5_1/103-2399305-5195831</link>
> </url>
> <url>
> <name>IMDB</name>
> <link>http://us.imdb.com/Details?0103064</link>
> </url>
> </dvd>
>
> Here is the xsd file:
>
> <?xml version="1.0"?>
> <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
> <sequence>
> <element name="dvd" type="DVD"/>
> </sequence>
> <complexType name="DVD">
> <simpleType name="integer">
> <restriction base="string">
> <enumeration value="Sci-Fi"/>
> <enumeration value="Action"/>
> <enumeration value="Horror"/>
> </restriction>
> </simpleType>
> <complexType name="URL">
> <sequence>
> <element name="name" type="string"/>
> <element name="link" type="string"/>
> </sequence>
> </complexType>
> <sequence>
> <element name="title" type="string"/>
> <element name="year" type="year"/>
> <element name="genre" maxOccurs="unbounded" type="Genre"/>
> <element name="url" maxOccurs="unbounded" type="URL"/>
> </sequence>
> </complexType>
> </schema>
>
> I know that it is reading the xsd file but the only thing that will stop
it
> from parsing is a syntax error in that file. In this example I have a bad
> enumeration value but I have tried a bunch of errors and none of them
raise
> an error.
>
> Sam
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
RE: Schema Validation
Posted by Sam Pullara <sa...@j2soft.com>.
Shouldn't the errors be fatal?
Sam
-----Original Message-----
From: Eric Ye [mailto:ericye@locus.apache.org]
Sent: Thursday, September 28, 2000 11:05 AM
To: xerces-j-dev@xml.apache.org
Subject: Re: Schema Validation
To catch the error messges, you need to implement a ErrorHandler and
register it on the parser object you created
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: "Sam Pullara" <sa...@j2soft.com>
To: "Xerces-J-Dev" <xe...@xml.apache.org>
Sent: Thursday, September 28, 2000 10:48 AM
Subject: Schema Validation
> Schema validation doesn't seem to working for me. Here is the code that I
> am using to parse the document:
>
> org.apache.xerces.parsers.DOMParser parser = new
> org.apache.xerces.parsers.DOMParser();
> parser.setFeature("http://xml.org/sax/features/validation", true);
> parser.setFeature("http://xml.org/sax/features/namespaces", true);
>
> Here is the xml file:
>
> <?xml version="1.0"?>
> <dvd xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="dvd.xsd">
> <title>Terminator 2: Judgement Day</title>
> <year>1991</year>
> <genre>Action</genre>
> <genre>Sci-Fi</genre>
> <genre>Comedy</genre>
> <url>
> <name>Amazon</name>
>
>
<link>http://www.amazon.com/exec/obidos/ASIN/B00004TRD8/o/qid=970113945/sr=8
> -12/ref=aps_sr_d_5_1/103-2399305-5195831</link>
> </url>
> <url>
> <name>IMDB</name>
> <link>http://us.imdb.com/Details?0103064</link>
> </url>
> </dvd>
>
> Here is the xsd file:
>
> <?xml version="1.0"?>
> <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
> <sequence>
> <element name="dvd" type="DVD"/>
> </sequence>
> <complexType name="DVD">
> <simpleType name="integer">
> <restriction base="string">
> <enumeration value="Sci-Fi"/>
> <enumeration value="Action"/>
> <enumeration value="Horror"/>
> </restriction>
> </simpleType>
> <complexType name="URL">
> <sequence>
> <element name="name" type="string"/>
> <element name="link" type="string"/>
> </sequence>
> </complexType>
> <sequence>
> <element name="title" type="string"/>
> <element name="year" type="year"/>
> <element name="genre" maxOccurs="unbounded" type="Genre"/>
> <element name="url" maxOccurs="unbounded" type="URL"/>
> </sequence>
> </complexType>
> </schema>
>
> I know that it is reading the xsd file but the only thing that will stop
it
> from parsing is a syntax error in that file. In this example I have a bad
> enumeration value but I have tried a bunch of errors and none of them
raise
> an error.
>
> Sam
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: Schema Validation
Posted by Eric Ye <er...@locus.apache.org>.
To catch the error messges, you need to implement a ErrorHandler and
register it on the parser object you created
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: "Sam Pullara" <sa...@j2soft.com>
To: "Xerces-J-Dev" <xe...@xml.apache.org>
Sent: Thursday, September 28, 2000 10:48 AM
Subject: Schema Validation
> Schema validation doesn't seem to working for me. Here is the code that I
> am using to parse the document:
>
> org.apache.xerces.parsers.DOMParser parser = new
> org.apache.xerces.parsers.DOMParser();
> parser.setFeature("http://xml.org/sax/features/validation", true);
> parser.setFeature("http://xml.org/sax/features/namespaces", true);
>
> Here is the xml file:
>
> <?xml version="1.0"?>
> <dvd xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="dvd.xsd">
> <title>Terminator 2: Judgement Day</title>
> <year>1991</year>
> <genre>Action</genre>
> <genre>Sci-Fi</genre>
> <genre>Comedy</genre>
> <url>
> <name>Amazon</name>
>
>
<link>http://www.amazon.com/exec/obidos/ASIN/B00004TRD8/o/qid=970113945/sr=8
> -12/ref=aps_sr_d_5_1/103-2399305-5195831</link>
> </url>
> <url>
> <name>IMDB</name>
> <link>http://us.imdb.com/Details?0103064</link>
> </url>
> </dvd>
>
> Here is the xsd file:
>
> <?xml version="1.0"?>
> <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
> <sequence>
> <element name="dvd" type="DVD"/>
> </sequence>
> <complexType name="DVD">
> <simpleType name="integer">
> <restriction base="string">
> <enumeration value="Sci-Fi"/>
> <enumeration value="Action"/>
> <enumeration value="Horror"/>
> </restriction>
> </simpleType>
> <complexType name="URL">
> <sequence>
> <element name="name" type="string"/>
> <element name="link" type="string"/>
> </sequence>
> </complexType>
> <sequence>
> <element name="title" type="string"/>
> <element name="year" type="year"/>
> <element name="genre" maxOccurs="unbounded" type="Genre"/>
> <element name="url" maxOccurs="unbounded" type="URL"/>
> </sequence>
> </complexType>
> </schema>
>
> I know that it is reading the xsd file but the only thing that will stop
it
> from parsing is a syntax error in that file. In this example I have a bad
> enumeration value but I have tried a bunch of errors and none of them
raise
> an error.
>
> Sam
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>