[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xsl-list
Subject:    RE: [xsl] Duplicate Nodes in XSL and transform them
From:       "Punnoose, Roshan" <punnooser () bah-systems ! com>
Date:       2007-01-30 19:57:03
Message-ID: B319B58E71D8C6469773C11686024E69BCB02B () exbah01 ! e-Space ! local
[Download RAW message or body]

That worked! Thanks!

Roshan Punnoose
Phone: 301-497-6039

-----Original Message-----
From: David Carlisle [mailto:davidc@nag.co.uk] 
Sent: Tuesday, January 30, 2007 2:30 PM
To: xsl-list@lists.mulberrytech.com
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()&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>



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
--~--



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic