Re: "sorted" axis (was: Remove duplicates from a node-set according to content)

Subject: Re: "sorted" axis (was: Remove duplicates from a node-set according to content)
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Jul 1999 11:00:13 -0400
At 99/07/28 14:46 +0000, Sebastian Rahtz wrote:
>My issue is the
>processing of a sorted list, and extracting just the different
>values. My data looks something like this:
>that is to say, a set of <stone>s containing several <person>s who
>have a <died> date. What I want to end up with is
> 1959
>   Another, Francis
> 1964
>   Godolphin, Francis
>   TheLast, Francis
>Can anyone suggest good ways of solving the problem using what we
>have now?  For those who are interested, David Carlisle _did_ find a nice
>solution for me (data:
>solution: but it has
>to use a little brute force and as a result is a trifle slow (it takes 
>35 minutes to process a 2.5Mbyte input file --- I have only tried it
>with XT, as it is written using July XSL syntax)

I don't think there is another approach with the given WD.

After writing the script below, I now see it is based on the identical
principles that David used, so it will probably also be just as slow.

............. Ken

T:\FTEMP>type test.xml
<?xml version="1.0"?>
<person><name><fnm>Francis d'Arcy
<person><name><fnm>Francis d'Arcy
<person><name><fnm>Francis d'Arcy
T:\FTEMP>type test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="";>

<xsl:template match="/">                              <!--root rule-->
  <xsl:for-each select="//person">           <!--process all people-->
    <xsl:sort select="died/date/yr"/>
    <xsl:variable name="year" select="died/date/yr"/>
                         <!--process only one entry per sorted year-->
    <xsl:if test="not(preceding-sibling::person[died/date/yr=$year])">
      <xsl:value-of select="$year"/>
                          <!--reselect only those in the given year-->
      <xsl:for-each select="//person[died/date/yr=$year]">
        <xsl:sort select="name/snm"/>
        <xsl:sort select="name/fnm"/>
        <xsl:value-of select="name/fnm"/><xsl:text>&#xa;</xsl:text>


T:\FTEMP>call xsl test.xml test.xsl test.txt
T:\FTEMP>type test.txt
Francis d'Arcy
Francis d'Arcy
Francis d'Arcy


G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.   
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Website:  XSL/XML/DSSSL/SGML services, training, libraries, products.
Publications:   Introduction to XSLT (3rd Edition) ISBN 1-894049-00-4
Next instructor-led training:   MS'99 1999-08-16  MT'99 1999-12-05/06

 XSL-List info and archive:

Current Thread