[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: checking for a 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|