Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Re: xsl variable problem

Thread Tools

Re: xsl variable problem

A. Bolmarcich
Posts: n/a
In article <(E-Mail Removed) >, Tom wrote:
> Hi,
> I am having problems creating a boolean variable that will tell me
> whether any sub-element contains a substring.
> the expression I am trying to use is:
> <xsl:variable name="test-output" select="contains(//value1, 'x2')"/>
> against this XML:
> <base>
> <value1>x1</value1>
> <value1>x2</value1>
> <value1>x3</value1>
> </base>
> I am always returned false which I find very confusing.
> Does anyone know how to do this?

To test if the value of any element value1 equals "x2" use

<xsl:variable name="test-output" select="//value1[.='x2']"/>

The value of the node set //value1 that the function contains uses
is the value of the first node of the node set, which is "x1" in
your example.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:sort using an xsl:variable as the sort key XML 2 09-05-2006 03:51 PM
xsl:variable is Constant or really Variable? Afshar Mohebbi XML 5 06-26-2006 01:13 PM
XSL Question tp xsl:for-each and xsl:variable XML 1 05-27-2005 09:25 PM
[XSL] : use array variable in XSL stylesheet MC XML 1 03-24-2005 10:41 AM
Difference between xsl:param and xsl:variable? Karsten Weinert XML 3 07-05-2004 04:58 PM