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

P

Porthos

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
 
P

Peter Flynn

Porthos said:
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)

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top