[jdom-interest] PI JDOM error

Jason Hunter jhunter at collab.net
Tue Feb 13 09:21:34 PST 2001


Works fine on the latest code snapshot.  I did a lot of builder work
since beta5.

C:/tmp/jdom 272 % java Tester
success!

-jh-

Paul Devenney wrote:
> 
> can anyone explain the following.....
> 
> <code below +errors>
> 
> I create a sample XML document using the JDOM Document class
> I then output it to a file.
> I then try to build a JDOM Document from the File (created by JDOM) - which
> gives me errors
> 
> after much painful searching I have found that the problem lies with where
> the PIs reside in the output. If they are at the end JDOM complains when it
> tries to build. Surely this is a bug, as JDOM puts the PIs there in the
> first place.
> 
> I have even checked my parser (xerces) and as expected it has no worries
> about PIs at the end of the file.
> 
> If anyone can explain how to solve this I would greatly appreciate it.
> 
> Paul Devenney
> 
> //-------------code-------------------
> 
> //create test document, using JDOM
>                 Document tDoc = new Document(new Element("IMG"));
>                 tDoc.addContent(new ProcessingInstruction("xml-stylesheet",
> "href=\"somefile.xsl\" media=\"html\""));
> 
>                 //Output to file bob.xml
>                 XMLOutputter tFormat = new XMLOutputter();
>                 tFormat.output(tDoc, new FileOutputStream("bob.xml"));
>                 //done
> 
>                 //read back in the file created using JDOM
>                 BufferedReader tIn = new BufferedReader(new FileReader("bob.xml"));
>                 SAXBuilder tBuilder = new SAXBuilder(false);
>                 tBuilder.build("bob.xml");
>                 System.out.println("success!");
> 
>                 //This gives errors!!
> 
> //-----------------------------------errors
> 
> org.jdom.JDOMException: null: null
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:320)
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:442)
>         at TestInt3.main(TestInt3.java:29)
> Root cause: java.util.EmptyStackException
>         at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:965)
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:302)
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:442)
>         at TestInt3.main(TestInt3.java:29)
> Exception in thread "main"
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list