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