Doctype cannot be added after a root element

"Prashant Deva" <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
Hi,
 I am trying to do an xslt transformation on an xml file using jdom
and i am getting this error msg-
ERROR:  'A DocType cannot be added after the root element'

the xslt file looks something like this -

  	 		 .c9Y6TC { color:#0000ff; } .c194KG { color:#602020; } .c49DIK {
color:#ac306d; } .c18YC0 { color:#d00020; } .c5M9S0 { color:#000090; }
.cLUY2 { color:#ea8f0f; } 		 	 <?xml version='1.0'?>

 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


 <xsl:output method="xml" doctype-system="taskDtd.dtd"/>
 <xsl:template match="/">

 <element>
     <xsl:apply-templates select="html/body/h2[1]/a"/>
     <xsl:apply-templates select="html/body/table[1]/tr[not(position()=1)]"/>
 </element>
 </xsl:template> 	

and the code that does the transformation looks something like this -

public Document transform(File sourceXml, File stylesheetFile)
    {

Document sourceDoc= new SAXBuilder().build(sourceXml);
       Transformer processor =
TransformerFactory.newInstance().newTemplates(new
StreamSource(stylesheetFile)).newTransformer();

        JDOMSource source = new JDOMSource(sourceDoc);
        JDOMResult result = new JDOMResult();


        processor.transform(source, result);

        return result.getDocument();
}


Can someone tell me why the error is happening?
Note that if i instead use the java's built xsl transformation instead
of jdom, it works perfectly.

Prashant
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.