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

Re: selecting nodes based on sibling values

Subject: Re: selecting nodes based on sibling values
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 23 Nov 2010 15:48:48 +0000
Re:  selecting nodes based on sibling values
I wasn't quite sure what you meant by the condition on keycode, e.g. whether they all need to be consecutive and whether they all need to appear before the next level 40.

Michael Kay
Saxonica

On 23/11/2010 15:33, Fabien Tillier wrote:
Hum. This one doesn't work.
I get 5 as an answer... I assume the keycode should be used somewhere within the for-each-group

-----Message d'origine-----
De : Michael Kay [mailto:mike@xxxxxxxxxxxx]
Envoyi : mardi 23 novembre 2010 16:25
@ : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Objet : Re:  selecting nodes based on sibling values


<xsl:variable name="gpsizes"> <xsl:for-each-group select="row" group-starting-with="row[level='40']"> <xsl:sequence select="count(current-group()) - 1"/> </xsl:for-each-group> </xsl:variable> <xsl:value-of select="max($gpsizes)"/>

Michael Kay
Saxonica

On 23/11/2010 14:45, Fabien Tillier wrote:
Hi List.
Let's say I have an XML like below...

<data>
	<row>
		<level>40</level>
		<keycode>1254.45.12</keycode>
	</row>
	<row>
		<level>50</level>
		<keycode>1254.45.12.7</keycode>
	</row>
	<row>
		<level>50</level>
		<keycode>1254.45.12.8</keycode>
	</row>
	<row>
		<level>50</level>
		<keycode>1254.45.12.9</keycode>
	</row>

	<row>
		<level>40</level>
		<keycode>99.25.6</keycode>
	</row>
	<row>
		<level>50</level>
		<keycode>99.25.6.45</keycode>
	</row>
	<row>
		<level>50</level>
		<keycode>99.25.6.46</keycode>
	</row>
</data>

What could be the XPath expression to get the maximum number of nodes of
level=50 in data those keycode starts like the level=40 line ?
Here the answer would be 3 as the maximum number of level = 50 nodes for
a given level = 40 is 3
I have tried several things, but I am stuck....
(I am using XSLT 2.0 on Saxon)


Thanks for lending me some neurons... Best regards, Fabien

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.