This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: access attribute in the parent element.
- To: xsl-list at mulberrytech dot com
- Subject: Re: access attribute in the parent element.
- From: WCB <WCBorg at LeapLink dot com>
- Date: Tue, 20 Jun 2000 20:06:30 -0700
- Cc: srirangababu thimmaiah <babuxsl at yahoo dot com>
- Reply-To: xsl-list at mulberrytech dot com
The abbreviated syntax to refer to the parent node is ".." [In case
you're interested, the full function is "from-parent(node())"]
To specify the attribute "first" use "@first". Stringing them together
with a "/" and substituting it in the select statement gives:
<xsl:template match="COUNTRY">
<xsl:value-of select="../@first"/>
</xsl:template>
This returns "john" when I tested it on Cocoon using:
<NAME first="john" last="mike">
<COUNTRY></COUNTRY>
</NAME>
If you want to get the attribute from the root instead, use
<xsl:value-of select="//@first"/>
Hope that helps,
-- Willy
At 06:32 PM 6/20/00 -0700, you wrote:
>How can i get the value of an attribute from a parent
>element/from an element in the top of the hirarchy.
>
><NAME first="john" last="mike">
> <COUNTRY><COUNTRY>
></NAME>
>
><xsl:templte match "NAME">
> <xsl:apply-templates/>
></xsl:template>
>
><xsl:template match="COUNTRY">
> <xsl:value of select=??, i want value of first>
></xsl:template?
>
>Regards.
>
>
>__________________________________________________
>Do You Yahoo!?
>Send online invitations with Yahoo! Invites.
>http://invites.yahoo.com
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list