javaxmljarxom

XOM testing at xubuntu are fail


I tried to use XOM at my easy project for generate xml files.

I follow instructions Installing XOM.

I added jar to my project it works perfect. But I can't run their easy test example:

To check your download you can run one of the sample programs found in the xom-samples.jar file. For instance, nu.xom.samples.PrettyPrinter class formats an XML document by inserting and removing white space around element boundaries. In Java 1.4 and later you can run it from the command line like this:

$ java -classpath xom-samples.jar:xom-1.1.jar nu.xom.samples.PrettyPrinter filename.xml

here is how it looks:

nazar@nazar-desctop:~/Downloads/XOM$ ls -lg
total 7032
drwxrwxrwx  5 nazar    4096 Dec 24 15:12 apidocs
drwxrwxrwx  3 nazar    4096 Apr 24  2013 bin
-rwxrwxrwx  1 nazar   39168 Apr 25  2013 build.xml
drwxrwxrwx  3 nazar    4096 Feb  6  2011 classes15
drwxrwxrwx 10 nazar    4096 Dec 24 15:12 data
drwxrwxrwx  3 nazar    4096 Feb  6  2011 fatsrc
-rwxrwxrwx  1 nazar   26430 Feb  6  2011 lgpl.txt
drwxrwxrwx  2 nazar    4096 Dec 24 15:12 lib
-rwxrwxrwx  1 nazar    1064 Feb  6  2011 LICENSE.txt
-rwxrwxrwx  1 nazar    4340 May  8  2005 mondial.dtd
-rwxrwxrwx  1 nazar 1226484 Jun 29  2005 mondial.xml
-rwxrwxrwx  1 nazar    1662 Feb  6  2011 overview.html
-rwxrwxrwx  1 nazar    1952 Feb  6  2011 project2.xml
-rwxrwxrwx  1 nazar    1616 Feb  6  2011 project.xml
-rwxrwxrwx  1 nazar    3067 Apr 24  2013 README.txt
drwxrwxrwx  3 nazar    4096 Feb  6  2011 src
drwxrwxrwx  3 nazar    4096 Feb  6  2011 src15
-rwxrwxrwx  1 nazar   44177 Apr 24  2013 Todo.txt
-rwxrwxrwx  1 nazar 5128917 Oct 12  2005 wsPerform_hoschek.pdf
drwxrwxrwx  2 nazar    4096 Dec 24 15:12 www
-rwxrwxrwx  1 nazar  313253 May 25  2013 xom-1.2.10.jar
-rwxrwxrwx  1 nazar   26623 Feb  6  2011 xom.graffle
-rwxrwxrwx  1 nazar  185519 May 27  2003 XOM.pdf
-rwxrwxrwx  1 nazar  125864 May 25  2013 xom-samples.jar
nazar@nazar-desctop:~/Downloads/XOM$ java -classpath xom-samples.jar:xom-1.2.10.jar nu.xom.samples.PrettyPrinter filename.xml
Due to an IOException, the parser could not check filename.xml

Solution:

Create items.xml at same directory:

<?xml version="1.0" encoding="ISO-8859-1"?>
<items xml:base="file:///home/nazar/Downloads/XOM/items.xml">
    <item>
        <product>
            <description>Ink Jet Refill Kit</description>
            <price>29.95</price>
        </product>
        <quantity>8</quantity>
    </item>
    <item>
        <product>
            <description>4-port Mini Hub</description>
            <price>19.95</price>
        </product>
        <quantity>4</quantity>
    </item>
</items>

Why this exactly happen?

Any suggestions?


Solution

  • filename.xml simply doesn't exist in this directory. Replace by the path of another XML file. The IOException tells you there was an error in the input. It's because Java can't find the file