[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: If statement and empty attribute

Subject: RE: If statement and empty attribute
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Tue, 6 May 2003 14:09:58 -0600
xsl if statement
> From: Karl J. Stubsjoen [mailto:karl@xxxxxxxxxxxxx]
> Sent: Tuesday, May 06, 2003 1:42 PM
> Subject:  If statement and empty attribute
> 
> Hi,
> I have an if statement which should evaluate to true when the 
> attribute
> viewable='true' or does not exist.  It would evaluate to 
> false only when the
> attribute viewable equals 'false'.  I've got the following:
> 
>         <xsl:if test="@viewable!='false'">
>              <xsl:value-of select="$currentVAL"/>&nbsp;
>         </xsl:if>
> 
> Which works, if the attribute viewable exists, but if it 
> doesn't exist then
> the statement is always false.  Any suggestions?  It needs to 
> evaluate to
> true if the attribute does not exist.

<xsl:if test="@viewable = 'true' or not(@viewable)">
  <xsl:value-of select="$currentVAL"/>&nbsp;
</xsl:if>

not() will return true if the expression in the argument evaluates to false
(a bit like 2 - (-2) = 4).  So, in this case if @viewable is not present,
then the first part of the above test will return false, but the or operator
will cause the processor to evaluate the second part, which will be true.

hth,
b.

| brian martinez                           brian.martinez@xxxxxxxxxxx |
| lead gui programmer                                    303.708.7248 |
| cheap tickets, part of trip network                fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.