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

RE: XSLT sort

Subject: RE: XSLT sort
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Thu, 20 May 2004 22:32:18 +0200
xslt sort variable
> -----Original Message-----
> From: Tomas Olsson [mailto:tomas.olsson@xxxxxxxxxxxxxxxxxxxxxxxx]
>

Hi,

> Im trying to get better performance by using keys, I have heard thats
> possible but I dont know how to do.
>

Well, depends on what you want to achieve.

Your initial code:

- applies templates to the Person nodes, sorted on @enamn
- for each Person node, applies templates to the @enamn node
- for each @enamn (one on each Person node), insert a copy of every Person
node with an @enamn equal to the current one

Unfortunately, we can only guess what the initial structure is that you're
trying to improve. My best guess is you want to create a variable containing
all unique @enamn values in the document, and use that to take control over
the template matching, like:

<xsl:key name="name-key" match="Person" use="@enamn" />

<xsl:template match="Katalog">
  <xsl:variable name="unique-names"
                select="Person[generate-id()=
                  generate-id(key('name-key',@enamn))]/@enamn" />
  <xsl:for-each select="$unique-names">
    <xsl:sort select="." order="ascending" />
    <xsl:apply-templates select="key('name-key',.)" />
  </xsl:for-each>
</xsl:template>

In this way, the sorting will only be performed on the group of unique names
instead of on all nodes in the document, which could mean a considerable
improvement in documents as large as you describe.


HTH!

Greetz,

Andreas

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.