aspose file tools*
The moose likes XML and Related Technologies and the fly likes Are these the correct steps to installing & running Xerces? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Are these the correct steps to installing & running Xerces?" Watch "Are these the correct steps to installing & running Xerces?" New topic
Author

Are these the correct steps to installing & running Xerces?

Kevin Thompson
Ranch Hand

Joined: May 04, 2001
Posts: 237
BACKGROUND INFORMATION: I have Java 1.4.0 installed as follows:
c:\jdk1.4.0

Step 01 - download the Xerces files to my c drive:
c:\Xerces-J-bin.2.2.1.zip
c:\Xerces-J-src.2.2.1.zip
c:\Xerces-J-tools.2.2.1.zip

Step 02 - unpack the zip files:
c:\jar xf Xerces-J-bin.2.2.1.zip
c:\jar xf Xerces-J-src.2.2.1.zip
The above two commands will place the contents into: c:\xerces-2_2_1
c:\jar xf Xerces-J-tools.2.2.1.zip
The above command will place the contents into: c:\tools

Step 03 - Set the path:
c:\set path=c:\jdk1.4.0\bin

Step 04 - Set the classpath:
c:\set CLASSPATH=c:\xerces-2_2_1\xercesSamples.jar;c:\xerces-2_2_1\xercesImpl.jar

Step 05 - Create an XML File named "intro.xml" and place inside xerces-2_2_1 folder:
<?xml version = "1.0"?>
<myMessage>
<message>Figure this stuff out!!!</message>
</myMessage>

Step 06 - Run the sample sax program named "Counter":
c:\xerces-2_2_1\java sax.Counter -v intro.xml
///////////////////////////////////////////////
The only results I get from my intro.xml file or any xml file for that matter is:
[Error] intro.xml:2:11: Document is invalid: no grammar found.
[Error] intro.xml:2:11: Document root element "myMessage", must match DOCTYPE root "null".
intro.xml: 125 ms (2 elems, 0 attrs, 0 spaces, 34 chars)

My Questions:
Are my results to be expected? Is this correct?
When I run the sample sax program named "sax.DocumentTracer" and "sax.Writer" I pretty much get same [Error] messages.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
You're asking it to validate (that's what the "-v" is for on the sax.Counter command line), but you have not declared any DTD.
Here's what I get when I take out the "-v":
% java sax.Counter intro.xml
intro.xml: 118 ms (2 elems, 0 attrs, 0 spaces, 31 chars)
And here's what the other two commands do for me:
% java sax.DocumentTracer intro.xml
setDocumentLocator(locator=org.apache.xerces.parsers.AbstractSAXParser$LocatorProxy@55d52)
startDocument()
startElement(uri="",localName="myMessage",qname="myMessage",attributes={})
characters(text="\n")
startElement(uri="",localName="message",qname="message",attributes={})
characters(text="Figure this stuff out!!!")
endElement(uri="",localName="message",qname="message")
characters(text="\n")
endElement(uri="",localName="myMessage",qname="myMessage")
endDocument()
% java sax.Writer intro.xml
<?xml version="1.0" encoding="UTF-8"?>
<myMessage>
<message>Figure this stuff out!!!</message>
</myMessage>
[ November 19, 2002: Message edited by: Ron Newman ]

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Brian Coates
Ranch Hand

Joined: Jul 03, 2001
Posts: 42
do you get errors running any of the other examples, like Counter?
Kevin Thompson
Ranch Hand

Joined: May 04, 2001
Posts: 237
Thanks! I dropped the "-v" on the run command and I get the exact same results that Ron does for sax.Counter and sax.DocumentTracer and sax.Writer. Thanks!
Now of course, there are still more Xerces run instructions that are not clear to me.
This text is from the "Installation" section of the Xerces Apache web site ==> "In order to compile the source code using Ant or to build the release distributions yourself, you must have the contents of Xerces-J-tools.2.2.1.zip on your classpath; i.e., you will need access to a version of ant.....For ease of use, we recommend extracting Xerces-J-tools.2.2.1.zip in your xerces root directory; the build.sh and build.bat scripts are written for this case."
//////////////////////////////////////////////
Background Story: There are no "readme.txt" files anywhere regarding the "tools" file folder, OR the "build.sh" file or the "build.bat" file.
My questions/comments:
1. In plain English, is this what they mean => If I want to make a change to the sax.Counter program, I need to put the entire tools folder in my classpath and run one of the provided batch files (either build.sh or build.bat).?
2. I guess the "build.bat" file is for windows? NOTE: the build.bat file they provided references two separate jar files that do not appear to exist, so maybe they have errors in their batch files? (I am talking about the c:\tools\bin\xjavac.jar file and also the c:\jdk1.4.0\lib\classes.zip file.)
3. I guess the "build.sh" file is for UNIX?
These are my steps to making my own source code changes (I tried to make out what they are doing in the build.bat file and follow it
Step 01 - set the Path:
c:\xerces-2_2_1>set path=jdk1.4.0\bin
Step 02 - set the JAVA_HOME per their batch file instructions:
c:\xerces-2_2_1> set JAVA_HOME=c:\jdk1.4.0\bin\java.exe;c:\jdk1.4.0\lib\tools.jar
Step 03 - set the CLASSPATH (add the tools jars):
c:\xerces-2_2_1> set CLASSPATH=
c:\xerces-2_2_1\xercesImpl.jar;c:\xerces-2_2_1\xercesSamples.jar;c:\xerces-2_1_1\xmlParserAPIs.jar;c:\tools\ant.jar;c:\tools\xercesImpl.jar;c:\tools\xml-apis.jar
Step 04: I save the sax.Counter program as sax.Counter1 and within the program change all occurances of "Counter" to "Counter1" and try to recompile as follows:
c:\xerces-2_2_1>javac sax.Counter1.java
I get these results:
error: cannot read : sax.Counter1.java
Step 05: Even the provided sax.Counter can not be recompiled:
c:\xerces-2_2_1>javac sax.Counter.java
I get these results:
error: cannot read : sax.Counter.java
MY CONCLUSION AT THIS POINT:
Their batch file instructions refer to two file that do not exit:
c:\jdk1.4.0\lib\classes.zip <- this zip file does not exist as part of JDK1.4.0
c:\tools\bin\xjavac.jar <- this jar file does not exist in Xerces-2_2_1
Interpreting batch files is not one of my strong points. Does anyone have suggestions?
[ November 21, 2002: Message edited by: Kevin Thompson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Are these the correct steps to installing & running Xerces?
 
Similar Threads
Are these correct steps to installing & running Xerces-2_2_1?
Fresher ! need help
Install problem jaxp_parser_impl missing
Trouble setting up and running Xerces-2_6_2
Problem including external jar to build.xml file Ant