On Tue, Nov 18, 2014 at 05:06:55AM -0000, Michael Friedman
sumarimike(_at_)hotmail(_dot_)com 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>
From there you -- if I'm understanding the use case, and it's late here,
so I could well not -- could presumably use sequences of range/start and
range/end values, sort it, and consume it from the front, to create the
aggregated ranges.
So, if the altered range elements are in $split,
<xsl:variable name="pairs">
<xsl:perform-sort select="$split/range/start | $split/range/end" >
<xsl:sort select="."/>
</xsl:perform-sort>
</xsl:variable>
and then you can consume $pairs pair-wise from the front, using
subsequence(), to get that actual ranges.
(XSLT has not been tested.)
Did that make any sense at all?
-- Graydon
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--