[thelist] XSLT question
Warden, Matt
mwarden at mattwarden.com
Tue Aug 14 09:15:46 CDT 2001
hi eric,
On Aug 14, Eric Cestari had something to say about [thelist] XSLT question
>But I am stuck in something I really can't get :
>I want the value of an attribute from the parent of an element.
>i.e. example XML file :
><page no="1" titre="Un titre de page">
> <texte id_pos="39">test de breve</texte>
> <texte id_pos="40">retest</texte>
></page>
>
>While rendering a 'texte' element I'd like to have access to the value
>of the 'no' attribute of the parent page ('1' in this case).
>
>I've tried (for the sake of the example):
><xsl:template match="texte">
> No Page : <xsl:value-of select="string(parent::attribute/@no)"/>
></xsl:template>
>But it doesn't work. Am I missing something ?
That looks to complicated. You can access nodes like directories: ./ is
the current node and ../ is the current node's parent node. So, to do what
you want, you'd do:
<xsl:value-of select="../@no" />
...while in the context of a match on the 'texte' node. Similarly, you can
access attributes of subnodes from the current node.
hth,
--
mattwarden
mattwarden.com
More information about the thelist
mailing list