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. Advertising

  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. 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. Replies:
    5
    Views:
    26,692
    Mike Schilling
    Mar 29, 2006
  2. RHNewBie

    null and NULL: is there any difference?

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

    Re: not declaring something to equal null

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

    Re: not declaring something to equal null

    jacob navia, Jan 24, 2009, in forum: C Programming
    Replies:
    2
    Views:
    287
    Richard
    Jan 26, 2009
Loading...

Share This Page