|
Subject: Re: [xsl] Apply for-each-group to a node subset From: Tony Graham <Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 21 Sep 2007 11:36:27 +0100 |
On Fri, Sep 21 2007 08:51:13 +0100, rocketraman@xxxxxxxxxxx wrote:
...
> I tried to simplify some of the expressions by using nested predicates
> but for some reason that didn't work e.g.
>
> <!-- process nodes after group -->
> <xsl:apply-templates select="*[preceding-sibling::g2[last()]]"/>
I'm still trying to get my head around what you want to do with your
template, but the likely reasons that your simplification doesn't work
are:
- The preceding-sibling axis is a 'reverse axis' [1], so the
immediately preceding sibling is at position 1 in the context for the
"[last()]" predicate, not (necessarily) the last position.
- You are selecting every child element that has a preceding 'g2'
sibling (since if there are any preceding 'g2' siblings, there will
be a last one of them even when there's only one).
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'.
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
======================================================================
[1] http://www.w3.org/TR/xpath20/#doc-xpath-ReverseAxis
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Apply for-each-group to a nod, Raman Gupta | Thread | Re: [xsl] Apply for-each-group to a, Raman Gupta |
| Re: [xsl] variable outside a for-ea, Colin Paul Adams | Date | Re: [xsl]Putting PHP Code in XSLT?, David Carlisle |
| Month |