Re: xsl variable problem

Discussion in 'XML' started by A. Bolmarcich, Jul 16, 2003.

  1. In article <>, 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.
     
    A. Bolmarcich, Jul 16, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karsten Weinert
    Replies:
    3
    Views:
    1,065
    Karsten Weinert
    Jul 5, 2004
  2. MC
    Replies:
    1
    Views:
    7,363
    David Carlisle
    Mar 24, 2005
  3. Replies:
    1
    Views:
    3,694
    A. Bolmarcich
    May 27, 2005
  4. Afshar Mohebbi
    Replies:
    5
    Views:
    6,146
    Afshar Mohebbi
    Jun 26, 2006
  5. Replies:
    2
    Views:
    9,359
    Martin Honnen
    Sep 5, 2006
Loading...

Share This Page