Subject: RE: [xsl] Duplicate Nodes in XSL and transform them From: "Punnoose, Roshan" <punnooser@xxxxxxxxxxxxxxx> Date: Tue, 30 Jan 2007 14:57:03 -0500 |
That worked! Thanks! Roshan Punnoose Phone: 301-497-6039 -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Tuesday, January 30, 2007 2:30 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Duplicate Nodes in XSL and transform them > That's why I thought that replacing the string using the XPath string > replace would be the best idea, but I didn't know how to process a node > set as a string and then convert it back to a node set. (Unless there is > a better way to do it.) you don't want to serialise, replace, then re-parse (which would take extension elements) you just need to apply the replacement separately to each text node. Abel has shown an xslt2 solution, if you are using xslt1 then a small modification of the code I sent earlier: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="*"> <xsl:param name="n"/> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates> <xsl:with-param name="n" select="$n"/> </xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match="text()[.='replaceMe']"> <xsl:param name="n"/> <xsl:text>replaced</xsl:text> <xsl:value-of select="$n"/> </xsl:template> <xsl:template match="anything"> <xsl:copy> <xsl:variable name="x" select="."/> <xsl:for-each select="(//node())[position()<4]"> <xsl:apply-templates select="$x/node()"> <xsl:with-param name="n" select="position()"/> </xsl:apply-templates> </xsl:for-each> </xsl:copy> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Duplicate Nodes in XSL an, David Carlisle | Thread | [xsl] PARAMS and VARIABLES in XSL, mark bordelon |
[xsl] PARAMS and VARIABLES in XSL, mark bordelon | Date | RE: [xsl] PARAMS and VARIABLES in X, Michael Kay |
Month |