|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Getting a node's cousin
>
> Given this XML
> <data>
> <parent>parent1
> <child>child1
> <grandchild>child1_of_child1</grandchild>
> <grandchild>child2_of_child1</grandchild>
> </child>
> <child>child2
> <grandchild>child1_of_child2</grandchild>
> <grandchild>child2_of_child2</grandchild>
> </child>
> </parent>
>
> when I am processing a grandchild, how can I access the immediate next set
of
> grandchildren, ie my sibling's children (hence my cousin term)
>
<xsl:template match="grandchild">
<P>Current Node : <xsl:value-of select="."/>
<BR />
Next Grandchild :
<xsl:choose>
<xsl:when test="position()=last()">
<xsl:value-of
select="parent::child/following-sibling::child[1]/child::grandchild[1]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="following-sibling::grandchild[1]"/>
</xsl:otherwise>
</xsl:choose>
</P>
</xsl:template>
The seventh line says : select the 'child' element of the parent axis
('child' denoting the element's QName), from there select the first
follwing sibling, and from there select the first child ('child' herein
denoting the children's axis).
Juliane.
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








