Subject: Re: [xsl] filter using contains with multiple values From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 3 Mar 2016 09:16:50 -0000 |
> On 2 Mar 2016, at 18:43, Raimund Kammering raimund.kammering@xxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Hi, > > I created a filter statement using two variables to a) specify the node of interest and b) the value to be matched: > > XSL is like this: > ... > <xsl:if test="*[name()=$filter]=contains(., $filter_value)b> *[name()=$filter] returns a set/sequence of element nodes; the contains() function returns a boolean. The result of comparing a node-set to a boolean depends on whether you are running 1.0 (or 2.0 with backwards compatibility enabled) or 2.0. In either case, I don't think it does what you want. I think you want test="*[name()=$filter][contains(., $filter_value)]" But perhaps you don't even want contains(). In your example, you are matching the whole value, rather than a substring. That suggests that an "=" test is wanted, not a "contains" test. So: test="*[name()=$filter][. = $filter_value]" Michael Kay Saxonica > b& > > feed with the following XML: > > <list> > <entry> > <keyword>Log</keyword> > <location>A</location> > </entry> > <entry> > <keyword>Log</keyword> > <location>B</location> > </entry> > <entry> > <keyword>Problem</keyword> > <location>A</location> > </entry> > <entry> > <keyword>Info</keyword> > <location>B</location> > </entry> > </list> > > so that setting bfilterb to bkeywordb and bfilter_valueb to bLogb will only match the first two bentryb nodes. Fine so far, but now > I would like to allow to pass in a flexile number of values for the bfilter_valueb, like bLogb or bInfob to match the first two plus the > last entry. I guess the solution would be to do this in kind of a loop, but how can this be done with bfilter_valueb being a > simple XSL variable or is exactly this the weakness of the approach? > > Ibrunning Saxon version: 9.1.0.8 so that Ibm able to use XSLT and XPath 2.0. > > Thanks, > Raimund
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] filter using contains wit, Graydon graydon@xxxx | Thread | [xsl] Table structure checking, how, Michael Müller-Hille |
Re: [xsl] Table structure checking,, Imsieke, Gerrit, le- | Date | Re: [xsl] Table structure checking,, Michael Müller-Hille |
Month |