Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang. IllegalState Exception: Root element not set  RSS feed

Martin Mikolajek
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i am trying to convert a XML-File to HTML with JAVA

String filename = "C:\\Temp\\Zinsen_mit_Jdom.xml";
try {
Document doc = new SAXBuilder().build
(new FileInputStream(filename));
Source xmlfile = new JDOMSource(doc);
JDOMResult htmlfile = new JDOMResult();
Transformer tf = TransformerFactory.newInstance().
newTransformer (new StreamSource


System.out.println("##### Ausgabe des html Dokumentes #####");
XMLOutputter outputter = new XMLOutputter();
outputter.output(htmlfile.getDocument(), System.out);
} catch (Exception e) { errMsg(e); }

Root element not set

java.lang.IllegalStateException: Root element not set
at org.jdom.Document.getContent(
at org.jdom.output.XMLOutputter.output(
at org.jdom.output.XMLOutputter.output(
at dom.Java_mit_XSL.main(

That's my XSL-File
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=""
<xslutput method="xml" />
<xsl:template match="/">

<xsl:apply-templates select="Zinsberechnung"/>


<xsl:template match="Zinsberechnung">
<xsl:apply-templates select="header">
<TABLE border="4pt">
<TR STYLE="font-size:16pt;color:red">
<xsl:apply-templates select="body">

<xsl:template match="header">
<h3>Zinsberechnung vom : <xsl:value-of select="@Datum"/></h3>
Betrag: <xsl:value-of select="Kreditbetrag"/><br/>
Rate: <xsl:value-of select="Rate"/><br/>
Zinssatz: <xsl:value-of select="Zinssatz"/><br/>

<xsl:template match="body">
<TR STYLE="font-size:16pt;color:blue">
<TD><xsl:value-of select="jahr"/></TD>
<TD><xsl:value-of select="betrag"/></TD>
<TD><xsl:value-of select="zinsen"/></TD>
<TD><xsl:value-of select="tilgung"/></TD>
<TD><xsl:value-of select="restwert"/></TD>

and this the XML

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Zinsen.xsl" ?>
<header Datum="Thu Aug 02 18:54:37 CEST 2007">

can anybody help me ???
what is wrong in my Files ??

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!