[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using contains with more than one string - XSLT2.0

Subject: Re: Using contains with more than one string - XSLT2.0
From: "Vishnu vishnu@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 Jan 2015 03:38:28 -0000
Re:  Using contains with more than one string - XSLT2.0
If we are using XSLT 2.0 then instead of constructing pattern contains(.,
'abc') or contains(., 'xyz') or contains(., 'pqr'), i think we can use
Quantified expressions some satisfies as below for the same example:-

some $a in ('abc','xyz','pqr') satisfies contains(.,$a)

Vishnu Singh

From: Michele R Combs mrrothen@xxxxxxx
Sent: Thursday, January 29, 2015 2:27 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Using contains with more than one string - XSLT2.0

Hi Michael --

Pretty sure.  Using equal would constrain it to exact matches, yes?  Which is
not what I want.  For example, I want to use "neg" to find "negatives"
"negative" "neg" "negs" and so on, since the exact phrasing may vary.


-----Original Message-----
From: Michael Kay mike@xxxxxxxxxxxx
Sent: Wednesday, January 28, 2015 3:53 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Using contains with more than one string - XSLT2.0

Either use matches() as David Sewell suggests, or construct an expression
along the lines

contains(., 'abc') or contains(., 'xyz') or contains(., 'pqr')

But are you sure you actually want contains()? People often misuse it,
thinking it means "Node N contains value V". For that, you want an "equals"

Michael Kay
+44 (0) 118 946 5893

On 28 Jan 2015, at 20:22, Michele R Combs mrrothen@xxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> I've done some googling on this but nothing seems quite to match what I want
to do.
> At the top of my style sheet I have this:
>   <xsl:variable name="target" select="'Photo'"/>
> Then later I do this to find all titles with that string in them:
>   <xsl:for-each
> So far so good, works great.  The problem comes when I want to tell the
contains function to match on any one of several strings, e.g. Photo or Neg or
Film.  So far I have tried the following but none of them work:
>   <xsl:variable name="target" select="'Photo|Neg'"/>
>   <xsl:variable name="target" select="'Photo'|'Neg'"/>
>   <xsl:variable name="target" select="'Photo' or 'Neg'"/>
>   <xsl:variable name="target" select="'Photo Neg'"/>
> If I must, I can stick the or'ed terms directly in the contains function
rather than using a variable, but when I tried a few variations on that, they
didn't work either.
> Thanks
> Michele
> +++++++++++++++
> Michele Combs
> Lead Archivist
> Special Collections Research Center
> Syracuse University Libraries
> 315-443-2081
> mrrothen@xxxxxxx
> scrc.syr.edu

"This e-mail and any attachments transmitted with it are for the sole use of
the intended recipient(s) and may contain confidential , proprietary or
privileged information. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original message. Any
unauthorized review, use, disclosure, dissemination, forwarding, printing or
copying of this e-mail or any action taken in reliance on this e-mail is
strictly prohibited and may be unlawful."

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.