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 ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • 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
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(
at com.discon.servlets.EditServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.tomcat.core.ServletWrapper.doService(
at org.apache.tomcat.core.Handler.service(

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 =;
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"?>
<Caption>1.News erstellt</Caption>
<Author>Holger Prause</Author>
Heute wurde eine neue News erstellt


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

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