xsl-list
[Top] [All Lists]

Re: testing for text in one of many elements

2003-06-19 08:29:13
Hi Mattison,

In psuedo-code I want to be like this:

  <xsl:if test="IfOneOfTheFunctionTagsHasThisValue('Function Uno')">
    <a href="function_one.asp">Func One</a>
  </xsl:if>

The IfOneOfTheFunctionTagsHasThisValue('Function Uno') test can be
written:

  Function = 'Function Uno'

When you use = in XPath and one of the operands is a node-set (in
this case a node-set of <Function> elements), then the test returns
true if *any* of the nodes in the node-set have the value of the other
operand.

If you prefer, you can alternatively use:

  Function[. = 'Function Uno']

Effectively, this filters the node-set of <Function> elements to
include only those whose value is 'Function Uno'. If the resulting
node-set has any nodes in it, then the result of the test is true; if
the resulting node-set is empty, then the result of the test is false.

In the current version of XPath 2.0, you can make this more explicit
by using:

  some $f in Function satisfies $f eq 'Function Uno'

but it's a bit long-winded in my opinion.
  
Cheers,

Jeni

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


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



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