Son KwonNam <> writes:
> But what I really wanted is not just add continuous numbers.
> The values to be added are strings.
>
> If there is not something like "str = str + value" in XSLT,
> I should use <xsl:for-each> more than two times.
> And I really did - I use <xsl:for-each> 8 times for every <td>, It gives
> me horrible performance.
This *can* be done recursively, you just have to carry around a
few extra parameters. Here's a solution that makes a node-set
($nodes) and passes it to the recursive template along with a
pointer that keeps track of the current position. It's not
pretty, but it works OK. As for performance, I'd be interested
to know how it compares.
This XML
- - -
<foo>
<item value1="one" value2="ONE"/>
<item value1="two" value2="TWO"/>
<item value1="three" value2="THREE"/>
<item value1="four" value2="FOUR"/>
</foo>
- - -
with this transformation
- - -
<xsl:stylesheet
version="1.0"
xmlns

sl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/foo">
<xsl:call-template name="concat-values">
<xsl:with-param name="num" select="1"/>
<xsl:with-param name="nodes" select="item"/>
<xsl:with-param name="string1" select="''"/>
<xsl:with-param name="string2" select="''"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="concat-values">
<xsl

aram name="num"/>
<xsl

aram name="nodes"/>
<xsl

aram name="string1"/>
<xsl

aram name="string2"/>
<xsl:choose>
<xsl:when test="$nodes[$num]">
<xsl:call-template name="concat-values">
<xsl:with-param name="num" select="$num + 1"/>
<xsl:with-param name="nodes" select="$nodes"/>
<xsl:with-param name="string1"
select="concat($string1,$nodes[$num]/@value1)"/>
<xsl:with-param name="string2"
select="concat($string2,$nodes[$num]/@value2)"/>
</xsl:call-template>
</xsl:when>
<xsl

therwise>
<xsl:text>String1 = </xsl:text>
<xsl:value-of select="$string1"/>
<xsl:text>
String2 = </xsl:text>
<xsl:value-of select="$string2"/>
</xsl

therwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
- - -
gives this output
- - -
<?xml version="1.0"?>
String1 = onetwothreefour
String2 = ONETWOTHREEFOUR
- - -
which you should be able to adapt to your situation.
Ben
--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/