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

Subject: Re: [xsl] Seeking an elegant XSLT function to check that a pair of numeric ranges are consecutive
From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 25 May 2024 17:00:04 -0000
 following-sibling::Record

should be following-sibling::Record [1]



On Sat, 25 May 2024 at 17:50, Roger L Costello <costello@xxxxxxxxx> wrote:

> Ohhh! That is a wicked cool solution. Thank you David!
>
>
>
> *From:* David Carlisle d.p.carlisle@xxxxxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
> *Sent:* Saturday, May 25, 2024 12:14 PM
> *To:* xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> *Subject:* [EXT] Re: [xsl] Seeking an elegant XSLT function to check that
> a pair of numeric ranges are consecutive
>
>
>
> <xsl: stylesheet xmlns: xsl="http: //www. w3. org/1999/XSL/Transform"
> xmlns: xs="http: //www. w3. org/2001/XMLSchema" version="3. 0">  <xsl: template
> match="Document">   <xsl: sequence select="every
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
> version="3.0">
>
>  <xsl:template match="Document">
>   <xsl:sequence select="every $r in //Range satisfies
> not($r/../following-sibling::Record/Range)
> or
> (xs:int(replace($r,'.*-',''))+1=
> $r/../following-sibling::Record/xs:int(replace(.,'-.*','')))
>    "/>
>  </xsl:template>
>
> </xsl:stylesheet>
>
>
>
> David
>
>
>
>
>
> On Sat, 25 May 2024 at 17:11, Bauman, Syd s.bauman@xxxxxxxxxxxxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> I wrote the test in Schematron, not XSLT (as it seems to me this is a
> constraint on the business rules of the input document, but to each his
> own), but should be pretty similar, no?
>
>
>
>     <sch:rule context="Range[following::Range]">
>
>       <!-- my maximum is either my value or, if I have a hyphen, then the
> value of what comes after said hyphen -->
>
>       <sch:let name="mymax" value="(if ( contains( ., '-') ) then
> substring-after( ., '-') else .) cast as xs:integer"/>
>
>       <!-- get next <Range> for texting -->
>
>       <sch:let name="next" value="following::Range[1]/string()"/>
>
>       <!-- its minimum is either its value or, if it has a hyphen, then
> the value of what comes before said hyphen -->
>
>       <sch:let name="nextmin" value="( if ( contains( $next, '-') ) then
> substring-before( $next, '-') else $next) cast as xs:integer"/>
>
>       <!-- in order to be consecutive, my max need be one less than the
> next min -->
>
>       <sch:assert test="$mymax + 1 eq $nextmin">Range following this one
> is not consecutive</sch:assert>
>
>     </sch:rule>
>
>
> ------------------------------
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2739265> (by
> email)
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/673357> (by
> email <>)

Current Thread