Re: [xsl] how to store attribute value?

Subject: Re: [xsl] how to store attribute value?
From: Oleg Tkachenko <olegt@xxxxxxxxxxxxx>
Date: Tue, 06 Aug 2002 14:30:17 +0200
Vinoth Palaniappan wrote:

I have a xml document as:
	<myroot  root_attribute="test_val">
		<a1/>
		<a1/>
	</myroot>
While processing the node "a1" using XSL, i need to access the value of
attribute "root_attribute" of it's parent.

That's very simple and straightforward - just say that you want value of attribite of parent element:


<xsl:template match="a1">
	<xsl:value-of select="../@root_attribute"/>
	<!-- Or the same in nonsimplified syntax -->
	<xsl:value-of select="parent::*/attribute::root_attribute"/>		
</xsl:template>

How can i access the attribute of some node in the template match of another
node?
That's what XPath expresions are for.

--
Oleg Tkachenko
Multiconn International, Israel


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



Current Thread