XML schema validation

O

Oskar Stuffer

Hi!

I'm using the msv tool which uses xerces to validate a XML document against a
XML Schema
definition.

This is my XML Schema definition:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="AnnoMeseCIG">
<xs:simpleType>
<xs:restriction base="xs:gYearMonth">
<xs:minInclusive value="2005-01"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>

Parsing this schema an exception is thrown:

Exception in thread "main" java.lang.ClassCastException
at com.sun.msv.datatype.xsd.TypeIncubator.derive(TypeIncubator.java:216)
at
com.sun.msv.reader.datatype.xsd.XSDatatypeExp$1.derive(XSDatatypeExp.java:92)
at
com.sun.msv.reader.datatype.xsd.RestrictionState.annealType(RestrictionState.java:41)
at
com.sun.msv.reader.datatype.xsd.TypeWithOneChildState.makeType(TypeWithOneChildState.java:42)
at com.sun.msv.reader.datatype.xsd.TypeState._makeType(TypeState.java:76)
at com.sun.msv.reader.datatype.xsd.TypeState.endSelf(TypeState.java:52)
at com.sun.msv.reader.SimpleState.endElement(SimpleState.java:100)
at org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:595)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
...

I tried some online validators that use xerces and they had the same problem
with my schema.
Is there a bug in xerces or is something wrong with my XML Schema definition?


Thanks for your help
Oskar Stuffer
 
M

Martin Honnen

Oskar Stuffer wrote:

I'm using the msv tool which uses xerces to validate a XML document
against a XML Schema
definition.

This is my XML Schema definition:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="AnnoMeseCIG">
<xs:simpleType>
<xs:restriction base="xs:gYearMonth">
<xs:minInclusive value="2005-01"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>

Parsing this schema an exception is thrown:

Exception in thread "main" java.lang.ClassCastException
I tried some online validators that use xerces and they had the same
problem with my schema.
Is there a bug in xerces or is something wrong with my XML Schema
definition?

I have tried your schema above and an XML instance I made up with both
MSXML 4 and with the Xerces Java parser used by the jEdit editor and its
XML plugin and both handled the schema without problems and depending on
the content of the sole element flagged a validation error if the
minInlusive constraint was not fulfilled.
Thus I don't think there is anything wrong with the schema.

What is msv, is that simply a validator? Perhaps the exception happens
because of some other problems unrelated to the validation features
Xerces provides.
 
P

Priscilla Walmsley

Hi,

I don't see any problem with your schema, and it validates for me using
Xerces-J 2.6.2.

Do you know what version of Xerces you are using?

What does your instance document look like?

Priscilla
 
M

Martin Honnen

Martin said:
Oskar Stuffer wrote:
What is msv, is that simply a validator? Perhaps the exception happens
because of some other problems unrelated to the validation features
Xerces provides.


If that is the tool here:
<http://www.sun.com/software/xml/developers/multischema/>
then it says: "It supports RELAX NG, RELAX Namespace, RELAX Core, TREX,
XML DTDs, and a subset of XML Schema Part 1." so perhaps it just can't
deal with the schema you have as it doesn't fit the supportd "subset of
XML Schema Part 1" in msv.
 
O

Oskar Stuffer

Hi,

Probably there is a problem with the msv tool so I will try to use the Xerces
library directly
to validate the XML output of the software I'm developing.


Thanks for your help,
Oskar Stuffer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top