Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Are there 'Null' and 'not equal to' test?

Reply
Thread Tools

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

 
 
Porthos
Guest
Posts: n/a
 
      01-03-2005
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

 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      01-03-2005
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_
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
base64.urlsafe_b64encode and the equal character Clodoaldo Python 4 03-28-2008 05:03 PM
Internet Sharing: Equal upload speeds but un-equal download speeds =?Utf-8?B?TkpU?= Wireless Networking 3 09-15-2007 06:22 AM
GridBagLayout question: Position 3 and 2 equal sized buttons problem ? Ulf Meinhardt Java 13 04-16-2006 09:41 PM
Finding 2 lists if there is equal element? Allerdyce.John@gmail.com C++ 3 02-27-2006 10:12 AM
Are all SIP softphones created equal (and will they work with Mitel) ? hal@nospam.com VOIP 6 04-02-2005 12:59 PM



Advertisments