xsl-list
[Top] [All Lists]

Re: [xsl] Testing for a specific word in a string

2008-03-05 05:31:16
Thanks Andrew, that worked....I got the syntax wrong!

On Wed, Mar 5, 2008 at 12:22 PM, Andrew Welch 
<andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:
On 05/03/2008, Aaron Johnson <artpunx(_at_)gmail(_dot_)com> wrote:
 > Hi...
 >
 >  I have a set of tests which assign various parameters. Sometimes the
 >  string values are similar and require the same variable to be used.
 >
 >  <xsl:when test="($tabName = 'Pilot')">pilotTab</xsl:when>
 >  <xsl:when test="($tabName = 'Pilot 2')">pilotTab</xsl:when>
 >  <xsl:when test="($tabName = 'Pilot 3')">pilotTab</xsl:when>
 >
 >  Instead of replicating the test over and over, I would like to extend
 >  the test to check for the word 'pilot' and so do away with repetition.
 >  I have tried various ways including 'contains' and 'begins-with' but I
 >  can't get it to work. I also looked at using subString but this seems
 >  to always require two values....which might work for 'Pilot,*' but not
 >  for 'Pilot'.

 contains($tabName, 'Pilot')

 ....should work fine - you don't mention why that doesn't work for you?

 You might prefer:

 'Pilot' = tokenize($tabName, ' ')

 if you want match 'Pilot' as a word (and are using 2.0)

 --
 Andrew Welch
 http://andrewjwelch.com
 Kernow: http://kernowforsaxon.sf.net/

 --~------------------------------------------------------------------
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
 To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
 or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
 --~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>