[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

local grouping

Subject: local grouping
From: Konrad Rokicki <krokicki@xxxxxxxxx>
Date: Tue, 23 Nov 2004 14:47:57 -0500
konrad rokicki
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.