test to find value

Discussion in 'XML' started by mike, Mar 13, 2005.

  1. mike

    mike Guest

    I have an xml structure like:

    <data>
    <struct>1,8,7,30</struct>
    </data>

    and I need to develop a test that finds this node in each of these
    cases, something like:

    should find because 1 is in the node
    <xsl:if test="struct='1'">

    should find because 1 and 8 is in the node
    <xsl:if test="struct='1,8'">

    should find because 1 and 8 and 7 is in the node
    <xsl:if test="struct='1,8,7'">

    should find because 1 and 8 and 7 and 30 is in the node
    <xsl:if test="struct='1,8,7,30'">

    any help is appreciated.

    Mike
    mike, Mar 13, 2005
    #1
    1. Advertising

  2. <xsl:variable name="x" select="concat(,normalize-space(struct),',')"/>

    <xsl:if test="contains($x,',1,') and contains($x,',8,')">
    contains 1 and 8
    ....
    David Carlisle, Mar 13, 2005
    #2
    1. Advertising

  3. mike wrote:

    > I have an xml structure like:
    >
    > <data>
    > <struct>1,8,7,30</struct>
    > </data>
    >
    > and I need to develop a test that finds this node in each of these
    > cases, something like:
    >
    > should find because 1 is in the node
    > <xsl:if test="struct='1'">
    >
    > should find because 1 and 8 is in the node
    > <xsl:if test="struct='1,8'">
    >
    > should find because 1 and 8 and 7 is in the node
    > <xsl:if test="struct='1,8,7'">
    >
    > should find because 1 and 8 and 7 and 30 is in the node
    > <xsl:if test="struct='1,8,7,30'">


    In XSLT there is
    <xsl:choose>
    <xsl:when test="struct = '1'">
    ...
    </xsl:when>
    <xsl:when test="struct = '1,8'">

    </xsl:when>
    </xsl:choose>
    perhaps you are looking for that?
    Or you can write an XPath expression with the boolean or
    <xsl:if test="struct = '1' or struct = '1,8'">

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 13, 2005
    #3
  4. I wrote

    <xsl:variable name="x" select="concat(,normalize-space(struct),',')"/>

    I meant

    <xsl:variable name="x" select="concat(',',normalize-space(struct),',')"/>
    David Carlisle, Mar 13, 2005
    #4
    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. AlecL
    Replies:
    3
    Views:
    1,188
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 11, 2007
  2. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    682
    Skybuck Flying
    Oct 4, 2009
  3. Wybo Dekker
    Replies:
    1
    Views:
    338
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    389
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    795
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page