  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Doctype cannot be added after a root element | Doctype cannot be added after a root element 2007-04-05 - By Prashant Deva
Back 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/youraddr@(protected)
|
|
 |