Subject: Re: [xsl] Best way of preserving comments? From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 03 Apr 2013 14:23:46 +0100 |
Using XSLT 2, this combination:
<xsl:strip-space elements = "*" /> <xsl:template match="element()|attribute()">... skip selected *|@* ... /> <xsl:template match="text()|@_ix"> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="comment()"> <xsl:copy-of select="."/><xsl:text> </xsl:text> </xsl:template>
is the best I could do to preserve the original comment and element layout, shown with beginning of input and output XML, below. Can this be improved? Losing empty lines is tolerable, losing line breaks is not so great.
Thanks Wolfgang
<xsl:template match="/comment()" priority="2"> <xsl:copy-of select="."/><xsl:text> </xsl:text> <xsl:text>
<xsl:template match="comment()"> <xsl:copy-of select="."/> <xsl:text>
<xsl:template match="/" priority="2"> <xsl:text> </xsl:text> <xsl:apply-templates/> <xsl:text>
________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Best way of preserving co, Andrew Welch | Thread | Re: [xsl] Best way of preserving co, Tony Graham |
Re: [xsl] Best way of preserving co, Andrew Welch | Date | Re: [xsl] Best way of preserving co, Tony Graham |
Month |