xsl-list
[Top] [All Lists]

Re: [xsl] XSLT2: Keys vs. xsl:choose to distinguish groups

2007-03-15 05:41:27
 
    <xsl:when test="current-group()[1] = A">
You prersumably didn't mean that (as it tests if the stribg value of the
current node is equal to the string value of its a child.


     <xsl:when test="current-group()[1]/self::A">

would work.

. My question is: Is it feasible (and reasonable) to avoid using 
xsl:choose here but instead select a group's treatment based on a key 

It's not clear what you have in mind here. If you use keys instead of
for-each group (muenchian grouping) then the nodes returned by the key
are the nodes that are returned by current-group() when using
for-each-group.

(because some groups might need the same kind of processing)?
You can make the xpath in the xsl:when clause as genearal as you need,
replacing
     <xsl:when test="current-group()[1]/self::A">
by
     <xsl:when test="not(current-group()[1]/self::Z[(_at_)foo='hmm'])">
if all groups except those starting with a Z foo="hmm" need the same
treatment.

 I think of having just a single call to the key function which would
then dispatch  the call to one out of a list of user-defined functions

key returns a sequence of nodes you still need to use a choose 9or apply
templates) to cause any action to be taken with those nodes.


David

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