xsl-list
[Top] [All Lists]

Re: Contexts that are atomic values

2005-06-21 15:24:29

Is this behavior normal?

Yes, or at least it will be. (It's best to say if you are using xslt2:-) 

distinct-values() as its name suggests returns values not teh nodes the
values they were in, so it's like going

<xsl:for-each select="(1,2,3,4)"

in which the current item would be the integers 1 2 3 4 but being
integers rather than nodes they can't be used as the base for any
relative XPath (or even / as that depends on the current dpcument)

you can go 
<xsl:variable name="input" select="/"/>
as a top level variable (or anywhere outside the for-each)
and then use

                 <xsl:apply-templates
                 select="$input/key('by-type',current())"/>
or equivalently


                 <xsl:apply-templates
                 select="key('by-type',current(),$input)"/>

Or perhaps more naturally don't use distinct-values at all, but ciew it
as a grouping problem

<xsl:for-each-group select="item" group-by="@type">
...

for-each-group groups the nodes themselves rather than just the values.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
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>