Re: [xsl] Filtering, xslt 2.0

Subject: Re: [xsl] Filtering, xslt 2.0
From: "Dave Pawson dave.pawson@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 31 Oct 2022 17:53:05 -0000
On Mon, 31 Oct 2022 at 17:49, Graydon graydon@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Oct 31, 2022 at 05:24:11PM -0000, Dave Pawson dave.pawson@xxxxxxxxx scripsit:
> > On Mon, 31 Oct 2022 at 16:47, Graydon graydon@xxxxxxxxx
> > <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> > > On Mon, Oct 31, 2022 at 04:35:10PM -0000, Dave Pawson dave.pawson@xxxxxxxxx scripsit:
> > > > <grin/> Not yet (will I ever be?) familiar with xslt 3.0
> > >
> > > Two has the sequence concept.
> > >
> > > param="a;b;c;d"
> > >
> > > <xsl:param name="rawMatch" as="xs:string" />
> > > <xsl:variable name="matchOptions" as="xs:string+"
> > > select="tokenize($rawMatch,';')" />
> >
> > (assume xslt 2.) - OK, happy with that.
>
> That should be completely fine in 2.0.
>
> > > Then the sequence-equals test will return true if it's any of the
> > > values in the param.
> >
> > Sequence-equals? 3.0? function? Google hasn't found this Graydon?
>
> In XPath 2.0 or greater, 'eq' is the "are these two atomic values the
> same?" test. ("comparison of values", sometimes.) So $A eq $B works if
> neither $A or $B have more than one value, but will throw an error if
> either is a sequence of two or more items.

<grin/> Told you 3.0 was new to me!


>
> The equals sign, =, U+003D, is the comparison on sequences.  It returns
> true if ANY member of $A can be found in $B.  (So (1,2,3) = (3,4,5).
> Also, (1,2,3) != (3,4,5) because some member of $A is NOT found in $B.)
>
> So you should be able to use
>
> <xsl:template match="data[membership = $matchOptions]"/>
> ...
> </xsl:template>
>
> and have it match all the data elements with membership element children
> where the string value of the element is equal to one of the string
> values in the $matchOptions sequence of strings.

Thanks, very clear.


>
> (I believe I have found where in the specs it discusses this before, but
> it's not easy to find and I do not presently recall which specification
> I should be looking at.  Making this easier to find would be a useful
> thing in 4.0, should XPath 4.0 there be.)

<hoping> Or better still, in Mikes updated XSLT book</hoping>

regards

-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.

Current Thread