This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Question on JDOM - esp. DOMOutputter

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I developed some classes or accesing xml Documents with JDom.
I like JDOM a lot cause of its little and uncomplicated Api.
I manipulate my xml-document - but then i want it to be used by xalan -
But Xalan only accepts org.w3c.dom.Documents but i have a org.jdom.Document - ok i thought i can use the XMLOutputter of JDOM to do the job.
But i always get a JDom Exception

org.jdom.JDOMException: Exception outputting Document: null
at org.jdom.output.DOMOutputter.output(DOMOutputter.java:168)
at com.discon.servlets.EditServlet.doPost(EditServlet.java:59)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:
04)
at org.apache.tomcat.core.Handler.service(Handler.java:286)

hmm i dont have any special processing instruction or namespaces in my xml document.
hers the source code that causes the error

File file = new File(xmlPath);
SAXBuilder builder = new SAXBuilder();
org.jdom.Document jdoc = builder.build(file);
DOMOutputter out = new DOMOutputter();
org.w3c.dom.Document w3cdoc = out.output(jdoc);
this should work :-(
and heres the xml File

<?xml version="1.0" encoding="ISO-8859-1"?>
<NewsDocument>
<NewsContent>
<NewsContentHeader>
<Caption>1.News erstellt</Caption>
<Date>06.07.2001</Date>
<Author>Holger Prause</Author>
<Id></Id>
</NewsContentHeader>
<NewsText>
Heute wurde eine neue News erstellt
</NewsText>
</NewsContent>
<NewsContent>

</NewsDocument>

I know i am using a Beta Version but maybe i am doing something wrong...

Ok thx a lot,
Holger
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!