This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Passing the current node list



"Paul Ackley" <Paul.Ackley@qwest.com> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]