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

Re: monotonous nbsp coding

Subject: Re: monotonous nbsp coding
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 13 Nov 2002 17:47:37 -0700 (MST)
normalize space nbsp
Greg Faron wrote:
> At 04:36 PM 11/13/2002, you wrote:
> >Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx> wrote:
> > >    <xsl:if test="string-length() = 0">
> >                                 ^^ Is this a typo?
> 
>    No.  When called without an argument, the context node is converted to a 
> string and used as the argument.  There are many alternative ways to test 
> whether the string value of the context node is the empty string, I simply 
> carried the one that the OP used so as not to confuse the reference.  Other 
> possibilities include
> string(.) = ''
> normalize-space() = ''
> normalize-space(.) = ''

The equality tests aren't even needed in those, since the fact that it's in a
test attribute means that the whole thing is treated as if it is wrapped in
boolean(). The boolean equivalent of an empty string or the number zero is
false.

> not(string(.))

Yeah, just like that.

> normalize-space(string-length(.)) = 0

That's a lot of extra work. The argument to normalize-space() ends up being a
number, which has to be coerced to a string, and then your equality test
converts it back into a number in order to compare it with zero.  
normalize-space() with no arguments and no comparisons is all you need.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 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.