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

Re: checking for a null value

Subject: Re: checking for a null value
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 16 May 2000 21:25:22 -0600 (MDT)
xsl if test null value
Next time, put a subject in your message headers.

> <DEPOSIT>
>   <A>fixedDeposit</A>
>   <B>RecurringDeposit</B>
> </DEPOSIT>
> 
> In the above mentioned case, some times the value of
> either A or B will be null, but while i extract the
> info through stylesheet, i have to check for the
> element which has null and i must not print it.
>
> how can we check for a null value in an element in XSL

The value is actually a text node child of the element node 'A':

<xsl:if test="A/text()">
will be true if there exists a text node child of any 'A' element children
of the current node

An element node's string-value is the concatenation of the character data
from all its text node descendants (children, grandchildren, etc). Often
it is easy to just test the element node itself:

<xsl:if test="normalize-space(A)">
will be true if the string-value of any of the 'A' element children of
the current node contain more than just whitespace characters

<xsl:if test="A=''">
will be true if the string-value of any of the 'A' element children of the
current node is empty

However, I think it is good practice to be a little more specific:

<xsl:if test="normalize-space(A[1]/text())"/>
will be true if any of the text node children of the first 'A' element
child of the current node contain more than just whitespace characters

   - Mike
___________________________________________________________
Mike J. Brown, software engineer, Webb Interactive Services
XML/XSL stuff: http://www.skew.org/    http://www.webb.net/


 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.