testing a field

Discussion in 'XML' started by Michael Hill, Jan 21, 2005.

  1. Michael Hill

    Michael Hill Guest

    I have a xslt stylesheet where I need to test for not one item, but
    many.

    I know I can do:

    <xsl:test="field='one'">

    but if I have a list to check like:

    'one', 'two', 'three' how would I check those.

    This does not work:

    <xsl:test="field='one|two|three'">

    Mike
     
    Michael Hill, Jan 21, 2005
    #1
    1. Advertising

  2. In article <Z2ZHd.2054$>,
    Michael Hill <> wrote:

    >This does not work:
    >
    ><xsl:test="field='one|two|three'">


    <xsl:if test="field='one'|field='two'|field='three'">

    -- Richard
     
    Richard Tobin, Jan 21, 2005
    #2
    1. Advertising

  3. Michael Hill

    Michael Hill Guest


    >>This does not work:
    >>
    >><xsl:test="field='one|two|three'">

    >
    > <xsl:if test="field='one'|field='two'|field='three'">
    >
    > -- Richard
    >


    Does not work. I am getting this error message:


    Expression does not return a DOM node.
    status=-->'Approved'|<--status='Proposed'

    Mike
     
    Michael Hill, Jan 21, 2005
    #3
  4. test="field[.='one' or . = 'two' or .='three']"

    David
     
    David Carlisle, Jan 21, 2005
    #4
  5. In article <TN6Id.2637$>,
    Michael Hill <> wrote:

    >> <xsl:if test="field='one'|field='two'|field='three'">


    Oops, I meant "or" not "|":

    <xsl:if test="field='one' or field='two' or field='three'">

    -- Richard
     
    Richard Tobin, Jan 21, 2005
    #5
  6. Michael Hill

    Joris Gillis Guest

    Tempore 02:36:58, die Friday 21 January 2005 AD, hinc in foro {comp.text.xml} scripsit Michael Hill <>:

    > I have a xslt stylesheet where I need to test for not one item, but
    > many.
    >
    > I know I can do:
    >
    > <xsl:test="field='one'">
    >
    > but if I have a list to check like:
    >
    > 'one', 'two', 'three' how would I check those.

    Hi,

    use the 'contains()' function an a string version of the possible values. Choose a separator that will not occur in the 'field' element's text nodes.
    In most occassions, this will work:
    <xsl:if test="contains('one,two,three',field)" />

    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    Laudeo W3C et dona ferens
     
    Joris Gillis, Jan 24, 2005
    #6
    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. Brian van den Broek
    Replies:
    3
    Views:
    844
    Jeremy Bowers
    Apr 3, 2005
  2. Brian van den Broek
    Replies:
    2
    Views:
    393
    Brian van den Broek
    Apr 5, 2005
  3. Chris

    Testing and Load Testing

    Chris, Mar 4, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    327
  4. Sound
    Replies:
    2
    Views:
    450
    Randy Webb
    Sep 28, 2006
  5. jr
    Replies:
    3
    Views:
    424
Loading...

Share This Page