[jdom-interest] schema validation fails after switching from Xerces 2.1.0 to 2.2.0

Norrman Per per.norrman at canovia.se
Tue Nov 5 05:34:13 PST 2002


Hi,

it's a Xerces bug. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13719
You can stop being lost.

/pmn

-----Original Message-----
From: Scott Cantor [mailto:scottcantor at yahoo.com] 
Sent: Tuesday, November 05, 2002 2:02 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] schema validation fails after switching from Xerces
2.1.0 to 2.2.0


As the subject says, none of my XML files and
associated schemas will validate using JDOM B8 with
the Xerces 2.2.0 parser.  Everything worked great
before using Xerces 2.1.0.  I am at a total loss
what's causing this other than it being a problem with
either JDOM B8 or Xerces 2.2.0.  Since I'm using JDOM
as the front end, I thought I'd start here first.

Environment: J2SDK 1.4.0.02 on Windows (also fails on
Solaris).

Test code:

************************
* schematest.java:

import org.jdom.*;
import org.jdom.input.*;
import java.io.*;

public class schematest
{
public static void main(String[] args)
{
try
{
SAXBuilder builder 
= new
SAXBuilder("org.apache.xerces.parsers.SAXParser",true);

builder.setFeature
("http://apache.org/xml/features/validation/schema",true);

builder.setFeature ("http://xml.org/sax/features/validation",true);

builder.setProperty
("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
",
 "file:///c:/test/test.xsd");

Document doc = builder.build(new File(args[0]));

System.out.println("loaded");
}
catch (Exception k)
{
   System.out.println("caught: " + k.toString());
   k.printStackTrace(System.out);
}
}
}

************************
* test.xml:

<?xml version="1.0" ?>

<test>

</test>

************************
* test.xsd:

<?xml version="1.0"?> 
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
version="1.0">

<xsd:element name="test" >
    <xsd:complexType>
        <xsd:sequence>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

</xsd:schema>

******

Assuming I have the following directory structure:

c:\test
  - jdom.jar
  - schematest.java
  - schematest.class
  - test.xsd
  - test.xml
c:\test\210
  - xercesImpl.jar (Xerces 2.1.0)
  - xmlParserAPIs.jar (Xerces 2.1.0)
c:\test\220
  - xercesImpl.jar (Xerces 2.2.0)
  - xmlParserAPIs.jar (Xerces 2.2.0)

I can do this:

set classpath=.\jdom.jar;.\210\xercesImpl.jar;.\210\xmlParserAPIs.jar;.
java schematest test.xml

or this:

java -Xbootclasspath/p:.\210\xercesImpl.jar;.\210\xmlParserAPIs.jar
schematest test.xml

...and it prints out this:

loaded

But if I do this:

set classpath=.\jdom.jar;.\220\xercesImpl.jar;.\220\xmlParserAPIs.jar;.
java schematest test.xml

or this:

java -Xbootclasspath/p:.\220\xercesImpl.jar;.\220\xmlParserAPIs.jar
schematest test.xml

...it prints out this:

caught: org.jdom.JDOMException: Error on line 3 of
document file:/C:/test/test.x
ml: cvc-elt.1: Cannot find the declaration of element
'test'.
org.jdom.JDOMException: Error on line 3 of document
file:/C:/test/test.xml: cvc-elt.1: Cannot find the
declaration of element 'test'.
        at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:363)
        at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:707)
        at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:689)
        at schematest.main(schematest.java:29)
Caused by: org.xml.sax.SAXParseException: cvc-elt.1:
Cannot find the declaration of element 'test'.
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)
        at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
        ... 3 more
Caused by: org.xml.sax.SAXParseException: cvc-elt.1:
Cannot find the declaration of element 'test'.
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)
        at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
        at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:707)
        at
org.jdom.input.SAXBuilder.build(SAXBuilder.java:689)
        at schematest.main(schematest.java:29)


Any ideas?

Thanks,
Scott











__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/ _______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.F-Secure.com/



More information about the jdom-interest mailing list