xsl-list
[Top] [All Lists]

Re: [xsl] if a condition is not met

2007-05-15 09:30:02



Can someone, btw, elaborate on the following: Why is it that a statement 
like current-group()[some-predicate]/following-sibling::* will return 
*all* following sibling and not only the elements that are part of the 
current group?

because (as you guessed) current_group() returrns original nodes, not
copies.

this is just the same as in xslt1, 

<xsl:for-each select="a">
  <xsl:copy-of select="following-sibling::*"/>

following-sibling::* here would select all siblings of the current (a)
node, the way that node was selected (in the for-each)  is irrelevant.

To workaround this, I know that you can treat the current-group() 
results as a document-node when you copy it into a variable and go from 
there.

copyig (might) be expensive, an alternative if you want to ensure that a
path expression only returns elements in the current group is to go

(pathexpression) intersect current-group()


But if you are doing
current-group()[some-predicate]/following-sibling::*  then it looks like
you are doing some further grouping on the current group so often it is
more natural to do

<xsl:for-each-group select="current-group()"
group-starting-with="node()[some-predicate]">
...

Then it is automatically constrained to just work within the current
group.

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>