Re: [xsl] Passing the current node list

Subject: Re: [xsl] Passing the current node list
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Wed, 22 Aug 2001 10:36:05 +0200
"Paul Ackley" <Paul.Ackley@xxxxxxxxx> wrote:

> I would like to know how (or if I even can) pass the current location in the
> XML tree from template to template?

One possibility is to pass the node as a parameter:
  <!-- template to be invoked -->
  <xsl:template match="foo">
    <xsl:param name="original-node"/>
     <!-- refer to $original-node for your node -->
  </xsl:template>

  <!-- invokation -->
  <xsl:template match="bar">
    <xsl:apply-templates select="document('foo')/foo">
      <xsl:with-param name="original-node" select="."/>
    </xsl:apply-templates>
  </xsl:template>

Be aware that parameters are not passed through built-in
templates, they will be dropped without notice. If necessary,
define a catch-all template:

  <xsl:template match="*">
    <xsl:param name="original-node"/>
    <xsl:apply-templates>
      <xsl:with-param name="original-node" select="."/>
    </xsl:apply-templates>
  </xsl:template>

If you have already a catch-all, or if you are using modes,
you may have to do more work.

There are probably other methods to achieve the effect you want
which may be easier to handle in your context.

HTH
J.Pietschmann

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


Current Thread