Are there 'Null' and 'not equal to' test?

Discussion in 'XML' started by Porthos, Jan 3, 2005.

  1. Porthos

    Porthos Guest

    Are there 'Null' and 'not equal to' operator that I can use in xsl:if
    statements? I assume that there must be, but I can't figure out the
    syntax.

    For example:

    <xsl:if test="@title DOES NOT EQUAL 'Little Red Riding
    Hood'"><xsl:value-of select="@title"></xsl:if>

    and

    <xsl:if test="books/humor IS NULL">Category is empty.</xsl:if>
    Thanks,

    -James
     
    Porthos, Jan 3, 2005
    #1
    1. Advertisements

  2. Porthos

    Peter Flynn Guest

    Porthos wrote:

    > Are there 'Null' and 'not equal to' operator that I can use in xsl:if
    > statements?


    <xsl:if test="@title"> means "true if the title attribute is specified"
    (either physically present or given as a default in the DTD/Schema)

    <xsl:if test="@title != 'foo'"> is the inequality operator

    > I assume that there must be, but I can't figure out the syntax.


    Did you try reading the XSLT spec? Sec 9.1 Conditional Processing with
    xsl:if has a link to the relevant section of XPath, productions 14 and
    21-24, which include the inequality operator:

    [23] EqualityExpr ::= RelationalExpr
    | EqualityExpr '=' RelationalExpr
    | EqualityExpr '!=' RelationalExpr

    Finding the existence syntax is admittedly a little more tricky: it's
    implicit in the handling of node-sets and Boolean values: "a node-set
    is true if and only if it is non-empty", so a test for a (non-existent)
    title attribute will return False.

    ///Peter
    --
    "The cat in the box is both a wave and a particle"
    -- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
     
    Peter Flynn, Jan 3, 2005
    #2
    1. Advertisements

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. Replies:
    5
    Views:
    30,250
    Mike Schilling
    Mar 29, 2006
  2. Bo Peng
    Replies:
    13
    Views:
    14,176
    Siemel Naran
    Jul 18, 2004
  3. RHNewBie

    null and NULL: is there any difference?

    RHNewBie, Sep 24, 2003, in forum: C Programming
    Replies:
    17
    Views:
    722
    Dan Pop
    Sep 26, 2003
  4. Nelu
    Replies:
    10
    Views:
    546
    Kaz Kylheku
    Jan 26, 2009
  5. Keith Thompson

    Re: not declaring something to equal null

    Keith Thompson, Jan 24, 2009, in forum: C Programming
    Replies:
    5
    Views:
    447
  6. jacob navia

    Re: not declaring something to equal null

    jacob navia, Jan 24, 2009, in forum: C Programming
    Replies:
    2
    Views:
    387
    Richard
    Jan 26, 2009
  7. Skybuck Flying

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

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    1,030
    Skybuck Flying
    Oct 4, 2009
  8. putty
    Replies:
    1
    Views:
    375
    putty
    Apr 5, 2005
Loading...