I have a loop of child nodes. For each one I need to go up the node structure to the parent and grab a value of a datatype, which will apply the appropriate colour to the child element.
The XSLT loops through the children fine, but I can't seem to get the value from the parent. It's just the syntax of the fourth line that's wrong I think. I thought this would grab the 'data' of the 'parent' of the current (./) node, but something's not right:
To select the parent of a node you can use ../ e.g. to get the projectColour property from the parent do <xsl:value-of select="../data [@alias = 'projectColour']"/>
Get parent datatype value within loop of children
Hi,
I have a loop of child nodes. For each one I need to go up the node structure to the parent and grab a value of a datatype, which will apply the appropriate colour to the child element.
The XSLT loops through the children fine, but I can't seem to get the value from the parent. It's just the syntax of the fourth line that's wrong I think. I thought this would grab the 'data' of the 'parent' of the current (./) node, but something's not right:
Can anyone point me in the right direction?
Thanks all
To select the parent of a node you can use ../ e.g. to get the projectColour property from the parent do <xsl:value-of select="../data [@alias = 'projectColour']"/>
http://umbraco.org/documentation/books/xslt-basics/xpath-axes-and-their-shortcuts
Parent Axis
The parent axis allows us to see the node immediately above the node in reference.
$currentPage/parent::node
$currentPage/../
I usually go for the "parent::node" but both should work. :)
is working on a reply...