RE: [xsl] xsl:param xsl:copy-of

Subject: RE: [xsl] xsl:param xsl:copy-of
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 15 Apr 2003 10:36:38 +0300
Hi,

> If I have a structure like - 
> 
> <xxx>
> <a>
> <b>
> <c>
> </xxx>
> 
> in a vairiable X1 can I do the follwing -
> 
> <xsl:call-template>
> <xsl:with-param name="X1" select="$X1(not(position() =
> 1))" />
> </xsl:call-template>
> 
> to get -
> 
> <xxx>
> <b>
> <c>
> </xxx>
> 
> for the next iteration?

Unless you use exslt:node-set or XSLT 1.1/2.0, you can't modify the node-set. You should consider passing the node-set $X1 as such, and have another parameter to define the index of the containing element to be processed, i.e.

<xsl:template name="foo">
  <xsl:param name="X1" select="/.." />
  <xsl:param name="index" select="1" />

  <xsl:if test="$i &lt;= count($X1/*)">
    <xsl:for-each select="$X1/*[position() = $index]">
      ...
    </xsl:for-each>
    <xsl:call-template name="foo">
      <xsl:with-param name="X1" select="$X1" />
      <xsl:with-param name="index" select="$index + 1" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>

Or you can pass

  <a />
  <b />
  <c />

(no wrapper element) and when recursing, pass if forwars with select="$X1[not(position() = 1)]". Did that make any sense to you?

Cheers,

Jarno - VNV Nation: Fallout


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread