[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Duplicate Nodes in XSL and transform them

Subject: RE: Duplicate Nodes in XSL and transform them
From: "Punnoose, Roshan" <punnooser@xxxxxxxxxxxxxxx>
Date: Tue, 30 Jan 2007 14:57:03 -0500
RE:  Duplicate Nodes in XSL and transform them
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:  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()&lt;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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.