|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: attribute
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








