[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] filter using contains with multiple values


Subject: Re: [xsl] filter using contains with multiple values
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 3 Mar 2016 19:21:07 -0000

On Thu, Mar 03, 2016 at 07:00:49PM -0000, Raimund Kammering
raimund.kammering@xxxxxxx scripsit:
> or as Michael suggested
> 
> <xsl:if test="*[name()= $filter][. = $filter_value]b>
> 
> it only matches the first of the two in the sequence if I use
> 
> <xsl:param name="filter_value" as="xs:string*" select="'Log',
> bInfo'b/>
> 
> to pass the parameter! Even an:
> 
> <xsl:value-of select=b$filter_valueb/>
> 
> only returns: bLogb where I would expect it to return the whole
> parameter! I seem to still miss some crucial point in making
> filter_value being understood as sequence here!?

You may be having trouble from the other side; . is the context value,
and will be understood as the string value of the element found by the
match, and that might not be what you expect.  It's pretty easy to get
some white space in there, for example, and = is an exact match. (You
won't, for example, match "info" with that filter value.)

<xsl:param name="filter_value" as="xs:string*" select="('Log', 'Info')"/>

is what I'd expect for explicitly creating a sequence.

<xsl:sequence select="$filter_value[2], $filter_value[1]"/>

Should show you whether or not you've really got a sequence;
<xsl:value-of/> creates a text node, which isn't what you want because
various rules about turning the sequence into text come into play.

-- Graydon


Current Thread