XML schema validation

Discussion in 'XML' started by Oskar Stuffer, Feb 28, 2005.

  1. 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
    Oskar Stuffer, Feb 28, 2005
    #1
    1. Advertising

  2. 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.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Feb 28, 2005
    #2
    1. Advertising

  3. 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

    ----------------------------------
    Priscilla Walmsley
    Author, Definitive XML Schema
    http://www.datypic.com
    ----------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Priscilla Walmsley, Feb 28, 2005
    #3
  4. Martin Honnen wrote:

    > 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


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



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Feb 28, 2005
    #4
  5. 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


    Priscilla Walmsley wrote:
    > 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
    >
    > ----------------------------------
    > Priscilla Walmsley
    > Author, Definitive XML Schema
    > http://www.datypic.com
    > ----------------------------------
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Oskar Stuffer, Mar 2, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page