Re: attribute

Subject: Re: attribute
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 14 Sep 2000 18:32:43 +0100
Hi,

><xsl:template match="temp">
><xsl:for-each select="item">
>...
></xsl:for-each>
></xsl:template>
>
>How can I reference an attribute of temp from within the for-each?
>I am saving the attribute to a variable outside of the for-each, is there a 
>better way?

Your XSLT above shows that 'item' is a child of 'temp', and your tree looks
like:

- temp
  +- @attr <-- the attribute you want
  +- item  <-- the current node within the xsl:for-each

Given this, you can see that to get from the 'item' element to the 'attr'
attribute, you need to go up to the 'temp' element (parent:: axis), and
then down again (attribute:: axis) to the 'attr' attribute:

  parent::temp/attribute::attr

Or, shorter:

  ../@attr

If the 'item' element hadn't been related as closely to the 'temp' element,
then setting the variable would have been the only way to do it.

I hope this helps,

Jeni

Jeni Tennison
http://www.jenitennison.com/


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


Current Thread
  • attribute
    • xsl list - Thu, 14 Sep 2000 11:39:47 EDT
      • Jeni Tennison - Thu, 14 Sep 2000 18:32:43 +0100 <=