Skip to main content

using JAXP 1.4 to validate a xml version 1.1 file

11 replies [Last post]
peterteichert
Offline
Joined: 2008-03-26
Points: 0

Hello JAXP users,
I am new to JAXP and I am having issues with validation of an xml 1.1 file.
- I use JAXP 1.4
- I assume that the XERCES2 JAVA Parser 2.9.1 is used in JAXP 1.4

The error message concerns the XERCES XML EntityManager.java : 2932

(com.sun.org.apache.xerces.internal.impl.XMLENtityManager$RewindableInputStream.read (XMLEntityManager.java:2932)

I use as an example java file a modified XDomEcho02 file from the tutorial

I appreciate your assistance very much

best regards

Peter Teichert

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
joehw
Offline
Joined: 2004-12-15
Points: 0

It's Xerces 2.7 that's included in JAXP 1.4. There have been many bug fixes but it's not 2.9.1.

What tutorial are you using? Can your sample program here? I can't find XDomEcho02.

--Joe

Message was edited by: joehw

peterteichert
Offline
Joined: 2008-03-26
Points: 0

Hello Joehw
I excuse for the long delay in answering;
Finally I use the sample program SourceValidator.java from Xerces 2.9.1.
When I validate an xml instance with an xml version 1.0 then all is Ok
When I validate the same instance with an xml version 1.1 then the is a parse error.

Doe I understand right; JAXP 1.4 does not handle xml 1.1 documents ?
In this case how can I use or install the xerces 2.9.1 ?

best regards

Peter

joehw
Offline
Joined: 2004-12-15
Points: 0

JAXP 1.4 does support xml 1.1. However, Xerces 2.9 has added more features and had better support.

To use Xerces 2.9.1 to replace the default implementation in the JDK, download and place all of the Xerces jars to $JAVA_HOME/lib/endorsed (refer to http://java.sun.com/j2se/1.4.2/docs/guide/standards/)

You may also use the -Djava.endorsed.dirs= endorsed-directory option.

Beast regards,
Joe

peterteichert
Offline
Joined: 2008-03-26
Points: 0

Hello Joe,
thanks for quick reply.

I am now trying to run the sample SourceValidator.java from xerces/jaxp but without success. (C:\Sun\xerces-2_9_1\samples\jaxp\SourceValidator)

- i am compiling the program in a batch file as
C:/Sun/SDK/jdk/bin/javac -Xlint:unchecked SourceValidator.java

- i am running the program in a batch file as
C:/Sun/SDK/jdk/bin/java SourceValidator -i C:/Home/teichert/cookbook/USDA_SR20/USDA_100STD.XML

result : parse error occurred - but there is no parse error !

thanks for responding

Peter

joehw
Offline
Joined: 2004-12-15
Points: 0

Hi Peter,

I tried the Xerces sample with data/schema files provided under the data directory. The -h option gives detailed instruction on how to use the samples. For SourceValidator, you may specify the schema using the -a option. For example, under the sample directory, I was able to run this:
java jaxp.SourceValidator -a ../data/personal.xsd -i ../data/personal.xml

--Joe

peterteichert
Offline
Joined: 2008-03-26
Points: 0

Hello Joe

Thanks for your time spending on the issue.

I have also no problem with the parsing of the files personal.xsd, personal.xml.

After changing the xml version to 1.1 in both files the same error occurred !

Greetings

Peter

joehw
Offline
Joined: 2004-12-15
Points: 0

Hi Peter,

You're very welcome.

You're right that the error appears after changing it to 1.1. But I was able to run it with the 2.9 jar files on classpath. e.g.:
java -cp .:../xml-apis.jar:../xercesImpl.jar jaxp.SourceValidator ...

Hope that works for you.

--Joe

peterteichert
Offline
Joined: 2008-03-26
Points: 0

Hi Joe,

thanks very much for clarifying the isse.

I am still struggling with javac, java in general.
I was not able to run your proposal in a dos batch file;
Now I installed Jcreator to learn in general
Being a xml, xsl, perl programmer many years I always made a big circle around java technology. All these pathes, classpathes, arguments and so on;

Anyway thanks for responding.

Greetings

Peter

joehw
Offline
Joined: 2004-12-15
Points: 0

A good IDE does make life a lot easier. JCreator seems to be a nice editor on Windows too according to http://en.wikipedia.org/wiki/JCreator. I personally like NetBeans for the many advanced features. The JAXP projects provide NetBeans profiles by default.

Since you mention DOS batch file, one of the things I noticed is that the path separator is semicolon on Windows vs colon on Unix/Linux. So when you try the commandline I provided previously, you'd need to change any colon to semicolon. Hope that'd work for you.

Regards,
Joe

peterteichert
Offline
Joined: 2008-03-26
Points: 0

Hi Joe,

yesterday I already tried to express BIG thanks to you, but my mail failed.
So the sample now works fine with JCreator and XML Version 1.1

Thanks again Joe for the great assistance in running JAXP/XERCES

regards

Peter

joehw
Offline
Joined: 2004-12-15
Points: 0

Hi Peter,

You're very welcome. I'm glad it works for you now.

Good luck in your future development! (and you're welcome to post your exp here)

Regards,
Joe