This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: attribute
- To: "xsl list" <xsl_list at hotmail dot com>
- Subject: Re: attribute
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Thu, 14 Sep 2000 18:32:43 +0100
- Cc: xsl-list at mulberrytech dot com
- Reply-To: xsl-list at mulberrytech dot com
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