[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Duplicate Nodes in XSL and transform them
Punnoose, Roshan wrote:
I see what you mean, but I guess the case I gave was a little too The case you gave was a little too complex (see below) 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.) I think you are making this very difficult and it don't need be. If I take the following rules based on your past mails and your above example (thanks!): 1) input xml can be anything, whole xml must be copied 2) somewhere in the input xml there is a string that must be replaced, but you don't know the path to that string 3) it must be replace with the nr of the current copy plus the string 'replace' This will suffice for those rules (and provide your example output from your example input, after you make it legal XML) with XSLT 2: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output indent="yes" /> <xsl:param name="nr-of-copies" select="5" /> <xsl:template match="/"> <xsl:variable name="anchor" select="." /> <xsl:for-each select="1 to $nr-of-copies"> <xsl:apply-templates select="$anchor" > <xsl:with-param name="iteration" tunnel="yes" select="."/> </xsl:apply-templates> </xsl:for-each> </xsl:template> <xsl:template match="node()"> <xsl:copy><xsl:apply-templates /></xsl:copy> </xsl:template> <xsl:template match="text()[matches(., 'replaceMe')]"> <xsl:param name="iteration" tunnel="yes"/> <xsl:text>replace</xsl:text> <xsl:value-of select="$iteration" /> </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
|