Subject: Re: [xsl] commenting an XML element [XSLT 1.0][xsltproc] From: pankaj.c@xxxxxxxxxxxxxxxxxx Date: Thu, 19 Aug 2010 09:40:08 +0530 |
Works for me now too. Yesterday was not my day. Little bit of tweaking in stylesheet and I got the result the way I wanted (as an EMPTY element). <!--<colspec colname="col1"/>--> <!--<colspec colname="col2"/>--> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!--Identity transform copies all items by default --> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- Comment <colspec> element, which will require during export --> <xsl:template match="colspec"> <xsl:comment> <xsl:apply-templates select="self::*" mode="comment" /> </xsl:comment> </xsl:template> <xsl:template match="*" mode="comment"> <xsl:value-of select="'<'"/> <xsl:value-of select="name()"/> <xsl:text> </xsl:text> <xsl:apply-templates select="@*|node()" mode="comment" /> <xsl:value-of select="'>'"/> </xsl:template> <xsl:template match="text()" mode="comment"> <xsl:value-of select="."/> </xsl:template> <xsl:template match="@*" mode="comment"> <xsl:value-of select="name()"/> <xsl:text>="</xsl:text> <xsl:value-of select="."/> <xsl:text>"</xsl:text> <xsl:text>/</xsl:text> </xsl:template> </xsl:stylesheet> But what about <thead valign="top">, which contains child elements and I wish to comment *only* <thead>. <thead valign="top"> <row> <entry rowsep="1" align="left">Abbreviation</entry> <entry rowsep="1" align="left">Dosage Interval</entry> </row> </thead> to <!-- <thead valign="top"> --> <row> <entry rowsep="1" align="left">Abbreviation</entry> <entry rowsep="1" align="left">Dosage Interval</entry> </row> <!--</thead> --> <xsl:template match="thead"> <xsl:comment> <xsl:apply-templates select="." mode="comment" /> </xsl:comment> </xsl:template> The above code does not seems to be working. Secondly how about reverting *commented* element using stylesheet. Is there a way around. Can somebody throw some ideas. Best, Pankaj
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] commenting an XML element, Martin Honnen | Thread | Re: [xsl] commenting an XML element, pankaj . c |
Re: [xsl] commenting an XML element, Florent Georges | Date | [xsl] Re Messages 56577, 78, 79, Etheridge, Stephen |
Month |