[jdom-interest] Bug or Misunderstanding?

Laurent Bihanic laurent.bihanic at atosorigin.com
Thu Jun 13 01:22:26 PDT 2002


Hi,

Crimson does not support XML Schemas. To validate documents again schemas, you 
have to use Xerces 2.0.

Laurent

Robert J. Sanford, Jr. wrote:
> I'm using the binary download version of B8 and have run into two minor
> issues. I'm not sure if I'm configured incorrectly or if there is a bug
> either in JDom or in the underlying parser (I have both the JAXP and Crimson
> ..jar files on my classpath so I assume that I'm using the JAXP API to the
> Crimson parser).
> 
> The first problem is that if I turn validation on my test document fails the
> validation even though XMLSpy 4.3 passes it. The exception being thrown is:
>  org.jdom.JDOMException: Error on line 2 of document
>    file:/f:/fantasy football/development/server/xml/fantasyFootball.xml:
>    Element type "Project" is not declared.
>  Caused by: org.xml.sax.SAXParseException: Element type "Project" is not
> declared.
>    at org.apache.crimson.parser.Parser2.error(Parser2.java:3160)
>    at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1322)
>    at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
>    at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
>    at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
>    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
> 
> The complete XML document looks like:
>    <?xml version="1.0" encoding="UTF-8"?>
>    <Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xsi:noNamespaceSchemaLocation="/dev/common/xmlutil/xml/xmlutil.xsd"
>       package="com.wobbet.football">
>       <Object package="player" className="Player">
>          <PrimaryKey>OID</PrimaryKey>
>       </Object>
>    </Project>
> 
> I know that this is an issue with validation because when I don't use
> validation the entire file is parsed, Elements are created by my custom
> JDOMFactory, and the XMLOutputter spews forth the file very nicely.
> 
> So why is XMLSpy saying the document is valid but JDOM is not? Should I be
> using Xerces instead of Crimson or am I doing something completely wrong?
> 
> My second problem I think is caused by the validation failure. In my xml
> schema I specify an attribute on the Object named "baseClass" which is
> optional and has a default value of "com.wobbet.framework.BaseClass".
> However, when I am iterating through the DOM tree and get the Object element
> and call getAttributeValue("baseClass") I get a null return value. If what I
> think is happening is happening then the failure to load/validate the schema
> results in the parser not knowing that there is a default value for the
> attribute. If that isn't the case then that means there is a bug somewhere
> in the parsing, I'm guessing in Crimson since JDOM should just be using the
> output from Crimson SAX to build the DOM and hopefully JDOM will recognize
> the default values returned from there properly).
> 
> So is this one or more bugs, a configuration issue, a mis-conception on my
> part or a combination of the three?
> 
> Many thanks and God's peace,
> 
> rjsjr
> 




More information about the jdom-interest mailing list