Hello all, I am new to this list. I'am using a small XSLT servlet filter to generate XHTML. Everything works fine. I have to generate and output some comments to the resulting XHTML code. This works only for the toplevel tag. Strange. Here is a kind of minimal reproduction of this behaviour:
*** XML <tag><anotherTag /></tag> *** XSLT <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" /> <xsl:template match="tag"> <xsl:comment>A comment</xsl:comment> <tag> <xsl:apply-templates /> </tag> </xsl:template> <xsl:template match="anotherTag"> <xsl:comment>Another comment</xsl:comment> <anotherTag /> </xsl:template> </xsl:stylesheet> *** Java code snippet for testing TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource( xsltFile)); DocumentSource source = new DocumentSource(xmlDocument); DocumentResult result = new DocumentResult(); transformer.transform(source, result); Document transformedDoc = result.getDocument(); XMLWriter writer = new XMLWriter(System.out, OutputFormat.createPrettyPrint()); writer.write(transformedDoc); *** Result/Output <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE tag PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!--A comment--> <tag> <anotherTag/> </tag> The comment above the "anotherTag" is missing. Why? If I remove the doctype attributes of the xsl:output method, everything works fine <xsl:output method="xml" /> *** Result/Output <?xml version="1.0" encoding="UTF-8"?> <!--A comment--> <tag> <!--Another comment--> <anotherTag/> </tag> I do not understand this behaviour and did not find an easy workaround. I have still some workaround ideas to check out, but I really would like to understand this behaviour first. Environment: Win XP Eclipse 3.3.2 dom4j-1.6.1 jdk1.6.0_03 Kind regards Stefan -- Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ dom4j-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dom4j-user
