Re: [xsl] Creating new, distinct groups of ranges from an aggregation of individual ranges

Subject: Re: [xsl] Creating new, distinct groups of ranges from an aggregation of individual ranges
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Nov 2014 06:02:43 -0000
On Tue, Nov 18, 2014 at 05:06:55AM -0000, Michael Friedman
sumarimike@xxxxxxxxxxx scripsit:
> Greetings, I'm trying to use XSLT 2.0 to create a new set of grouped
> ranges based on the overlap of an aggregation of a set of
> non-contiguous individual ranges. Example: Given a range of numbers as
> an individual set:1. <range>150-202</range>2. <range>201-225</range>3.
> <range>201-204</range>4. <range>205-234</range>5. <range>226-234,
> 250-260</range>
[snip]
> I've been using <xsl:sequence> to find all the numbers of a single
> range, so I can do compares against individual numbers in the entire
> range, if necessary. But, it seems like it may be easier to just work
> with the boundaries: the start and end points and see if a value falls
> within it, somehow, rather than iterating repetitively through
> enumerations of sequences.

Well, you could -- since this is a copy being processed toward XSL-FO,
not canonical archival content -- start splitting things inside the
range elements:

<range>
    <xsl:for-each select="tokenize(string(.),',')">
        <start><xsl:value-of select="tokenize(.,'-')[1]"/></start>
        <end><xsl:value-of select="tokenize(.,'-')[last()]"/></end>
    </xsl:for-each>
</range>

Current Thread