[jdom-interest] PI JDOM error
Paul Devenney
paul.devenney at durham.ac.uk
Sat Feb 10 03:28:38 PST 2001
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"
More information about the jdom-interest
mailing list