This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Question on JDOM - esp. DOMOutputter

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Nothing? Or something? Like this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic