xsl-list
[Top] [All Lists]

What to use instead of a mutable variable ?

2003-08-16 20:52:09
Hello everebody,

I have something like this code in my xsl

<xsl:template match="insertItem">
<xsl:for-each select="$book/itens"> <xsl:apply-templates select="$layout//insertItens/*" />
   </xsl:for-each>
</xsl:template>

<xsl:template match="insertName">
   <xsl:value-of select="$book/itens/name"/>
</xsl:template>

<xsl:template match="@*|*">
   <xsl:copy>
<xsl:apply-templates select="@*|node()" /> </xsl:copy>
</xsl:template>

How can I make the template "insertItens" to use a diferrent name everytime it is called? I want to achieve something like

<xsl:template match="insertName">
    <xsl:param name="position" />
   <xsl:value-of select="$book/itens/name[$position]"/>
</xsl:template>

though I ca't call this template directly, because there is some nodes tha need to be "copied" to the output first when the "for each" is being processed. I needed an alterable global variable, but that is not possible in XSL.

Did I explain the situation correctly?


Thanks.


<Prev in Thread] Current Thread [Next in Thread>