This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Check a node in my XML contains a particular value!


Hi George,

> At present I am using <xsl:when
> test="starts-with(wcc/wcc-category-oid, 'CSE')"> and my research
> comes back with the usage of <xsl:when
> test="contains(wcc/wcc-category-oid, 'CSE')">, but this only checks
> that both string values are identical (I think, correct me if I am
> wrong).

The starts-with() function tests whether the value of the node that
you select starts with a particular string; the contains() function
tests whether the value of the node you select contains a particular
string. If you want to test whether the string is identical to the
node, then you'd use =.

For example,

  starts-with('CSE is what this is', 'CSE')

would be true, as would:

  contains('CSE is what this is', 'CSE')
  contains('This is a CSE', 'CSE')

Is that not what you're getting? Perhaps you're testing the wrong path
-- what's your context node at the point where you're doing the test?
What node are you processing at that point? You need to make sure that
the path is relative to that node, so for example if you're already on
the wcc element, you need to do just:

  contains(wcc-category-oid, 'CSE')

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]