| re: xslt: for-each group, grouping by child nodes?
oops--contrary to my typo in the title, i'm using for-each-group, not
grouping by for-each :)
jon
jon|k wrote:[color=blue]
> hi all--
>
> i need to do a transformation that removes duplicates (among other
> things). to accomplish that, i'm trying to use for-each-group, but it
> doesn't work. i need to select for duplicates by looking at the child
> node sequence (see sample below). note that when i do an xsl-message on
> the group-by expression inside the for-each-group, it has exactly what
> i'd like to group by listed, but i guess it doesn't like to have a
> sequence of nodes in the group-by? (it repeats way too many times, and
> i'm thinking it's because the expression in the group-by clause is a
> sequence of attribute nodes and not converted to a string or something
> that can be simply "eq"ed?)
>
> <xsl:for-each-group select="(//sentence|//node)"
> group-by="./child::*/(@cat|@pos)">
> <xsl:apply-templates select="current-group()" />
> </xsl:for-each-group>
>
> here's sample data. i only want the template run ONCE for each
> combination of sentence/node + the cat/pos attributes of the first
> level children (e.g., only run for the nodes that i've starred
> [although it could be any similar node; as long as it's just run
> once]). note that i don't care what's two levels down, just what's on
> the first level.
>
> example:
> <sentence id="1" *>
> <node cat="A" *>
> <word pos="E" />
> <word pos="F" />
> </node>
> <node cat="D" * />
> <word pos="B" />
> </sentence>
> <sentence id="2" *>
> <node cat="A" * />
> <node cat="D" />
> </sentence>
> <sentence id="3">
> <node cat="A" />
> <node cat="D" />
> </sentence>
>
> what am i doing wrong, or have i tried to tackle this completely
> incorrectly? thanks in advance for any help you can give!
>
> jon[/color] |