[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Getting a node's cousin

Subject: RE: Getting a node's cousin
From: "Harbarth, Juliane" <jhb@xxxxxxxxxxxxxx>
Date: Wed, 11 Aug 1999 17:07:10 +0200
xsl getting first child node
>
> 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.