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

Re: Apply for-each-group to a node subset

Subject: Re: Apply for-each-group to a node subset
From: Tony Graham <Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 Sep 2007 16:51:48 +0100
Re:  Apply for-each-group to a node subset
On Fri, Sep 21 2007 16:28:47 +0100, rocketraman@xxxxxxxxxxx wrote:
> Tony Graham wrote:
...
>> You may do better with:
>> 
>>    <xsl:apply-templates
>>       select="*[preceding-sibling::*[1][local-name() = 'g2']]"/>
>> 
>> which selects child elements whose first preceding sibling element (of
>> any type) is a 'g2'.
>
> That selects only the first preceding sibling, which results in only
> g1 nodes.

Sorry about that.  I had already worked out that I'd solved the wrong
problem.

...
> It works, but I still don't understand why a simple nested predicate
> does not work:
>
>      <!-- process nodes after group -->
>      <xsl:apply-templates select="*[preceding-sibling::g2[last()]]"/>
>
> The way I read this is: apply templates to all the nodes that have the
> LAST g2 as a preceding sibling, which should apply templates to all
> nodes n3 to n4.

It doesn't do as you expect because the current node list has changed
for each predicate.

This will work:

   <xsl:apply-templates
     select="g2[last()]/following-sibling::*"/>

Regards,


Tony Graham.
======================================================================
Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx   http://www.menteithconsulting.com

Menteith Consulting Ltd             Registered in Ireland - No. 428599
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
----------------------------------------------------------------------
Menteith Consulting -- Understanding how markup works
======================================================================

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.