[xsl] Re: Seeking an elegant XSLT function to check that a pair of numeric ranges are consecutive

Subject: [xsl] Re: Seeking an elegant XSLT function to check that a pair of numeric ranges are consecutive
From: "Roger L Costello costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 25 May 2024 21:02:25 -0000
Fantastic responses - thank you!

Recall the problem: determine if an integer range has no gaps in it. Till now,
I have been thinking that the way to solve the problem is to perform a series
of checks on pairs of ranges. But maybe there is a more general way of looking
at the problem ...

Recall the XML document:

<Document>
    <Record>
        <Range>0-2</Range>
    </Record>
    <Record>
        <Range>3-7</Range>
    </Record>
    <Record>
        <Range>8</Range>
    </Record>
    <Record>
        <Range>9-15</Range>
    </Record>
</Document>

If we extract all the ranges, we get this sequence:

(0-2, 3-7, 8, 9-15)

Now the problem may be succinctly restated as:

    Is the sequence connected?

It seems like XSLT should provide a built-in function that evaluates a
sequence for connectedness and returns true (the sequence is a connected
sequence) or false (the sequence is not a connected sequence).

Does looking at the problem from the perspective of evaluating the
connectedness of an entire sequence rather than from the perspective of
evaluating the connectedness of a pair of ranges ... does that provide insight
into a different/better way of solving the problem?

As far as I know, XSLT does not provide a built-in function that evaluates a
sequence (such as the one shown above) for connectedness. If XSLT did have
such a function, what would be the name of the function?

/Roger

Current Thread