Subject: [xsl] local grouping From: Konrad Rokicki <krokicki@xxxxxxxxx> Date: Tue, 23 Nov 2004 14:47:57 -0500 |
Hi all, I have a grouping problem like this: <g> <line x="1"/> <line x="2"/> </g> <g> <line x="1"/> <line x="1"/> <line x="2"/> </g> and so on.. For each <g> element I want to group the children into sub elements based on the value of x, so like this: <g> <g> <line x="1"/> </g> <g> <line x="2"/> </g> </g> <g> <g> <line x="1"/> <line x="1"/> </g> <g> <line x="2"/> </g> </g> I'm able to do this using the Muenchian Method and the extension function intersection(). When I come across a <g> I want to iterate across each possible x value that its children have and create a child <g> for each one. So the code looks like this: <xsl:key name="mykey" match="line" use="@x"/> <xsl:template match="g"> <xsl:variable name="children" select="child::*"/> <xsl:for-each select="child::*[count(.|xalan:intersection(key(mykey, @x, $children)[1]) = 1]"> <!-- build the inner g's --> </xsl:for-each> </xsl:template> This works, but it is extremely slow. Does anyone have a more efficient/faster way of doing this? It seems like it would be a common problem, but I couldn't find any info about it. Thanks, Konrad
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] includes, Jeni Tennison | Thread | Re: [xsl] local grouping, Jeni Tennison |
RE: [xsl] document() path relative , "Robert Sösemann" | Date | RE: [xsl] document() path relative , Passin, Tom |
Month |