|
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: Sun, 26 May 2024 14:15:18 -0000 |
Another mind-blowing solution. This one from Michael Kay:
<!--
Determine if the ranges in $seq are consecutive.
$seq = (0-2, 3-7, 8, 9-15) returns true
$seq = (0-3, 3-7, 8, 9-15) returns false
-->
<xsl:function name="f:isConsecutive" as="xs:boolean">
<xsl:param name="seq"/>
<xsl:variable name="seq-with-to" as="xs:integer*">
<xsl:evaluate xpath="$seq ! replace(., '-', ' to ') =>
string-join(',')"/>
</xsl:variable>
<xsl:sequence select="deep-equal($seq-with-to, $seq-with-to[1] to
$seq-with-to[last()])"/>
</xsl:function>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Re: Seeking an elegant XS, Dimitre Novatchev dn | Thread | Re: [xsl] Re: Seeking an elegant XS, Dimitre Novatchev dn |
| Re: [xsl] Seeking an elegant XSLT f, Michael Kay mike@xxx | Date | Re: [xsl] Re: Seeking an elegant XS, Dimitre Novatchev dn |
| Month |