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 16:13:48 -0000 |
<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 <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Seeking an elegant XSLT f, Bauman, Syd s.bauman | Thread | Re: [xsl] Seeking an elegant XSLT f, David Carlisle d.p.c |
Re: [xsl] Seeking an elegant XSLT f, Bauman, Syd s.bauman | Date | Re: [xsl] Seeking an elegant XSLT f, David Carlisle d.p.c |
Month |