This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Preserve comments in the XSL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Preserve comments in the XSL" Watch "Preserve comments in the XSL" New topic
Author

Preserve comments in the XSL

Nira Shavitt
Greenhorn

Joined: Jul 26, 2004
Posts: 19
hi,

I'm using xsl for a transformer to write a a DOM to a file, and I'm getting a problem - it eliminates the comments. Does anyone know how to reserve them?

This is the transformer I have:

private static final String TRANSFORMER_STRING = "<?xml version=\"1.0\"?>" +
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" xmlns:html=\"http://www.w3.org/TR/REC-html40\" version=\"1.0\" stlptimize=\"true\" stl:version=\"0.6\">" +
"<xslutput encoding=\"ISO-8859-1\" method=\"xml\" indent=\"no\"/>" +
"<xsl:template match=\"*|@*\">" +
"<xsl:copy>" +
"<xsl:apply-templates select=\"*|@*|text()\"/>" +
"</xsl:copy>" +
"</xsl:template>" +
"</xsl:stylesheet>";
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Stripped of all the junk required to make it into a Java string, here's what you are matching:So, you aren't matching comments. And since the built-in processing rule for processing comments is to do nothing, they do not get copied to the output. To change that to match comments as well, do this:You might have to change your xsl:apply-templates element as well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Preserve comments in the XSL
 
Similar Threads
HTML Form > XML
How to write the xsl for this...
to EXACT Dublicate an xml file[xml->xml] via Java TransformerFactory classes and XSTL well I do not
[XSLT] remove a particular node
How to delete empty tag from XML