• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Preserve comments in the XSL

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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\" stl:optimize=\"true\" stl:version=\"0.6\">" +
"<xsl:output encoding=\"ISO-8859-1\" method=\"xml\" indent=\"no\"/>" +
"<xsl:template match=\"*|@*\">" +
"<xsl:copy>" +
"<xsl:apply-templates select=\"*|@*|text()\"/>" +
"</xsl:copy>" +
"</xsl:template>" +
"</xsl:stylesheet>";
 
Sheriff
Posts: 28368
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic