[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|