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

Re: xpath2 functions returning ()

Subject: Re: xpath2 functions returning ()
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 4 Jan 2002 15:49:09 +0000
example xpath2
David,

> Xpath 2 seems to want to treat () special in many contexts. Most of
> which seem unfortunate:-) The example above is one, sum() returning
> the empty sequence instead of 0 is another (that seems to be much
> worse, and will mean that you will almost always have to special
> case any value returned from sum() to check if it is empty and if so
> replace it with 0)

I can understand the use of the empty sequence in *some* of the cases,
where the function is supposed to return a value for which there is no
legal and sensible 'null' value. For a QName (the result of the name()
function), for example, what would you use as a 'no QName' value? Or
for a dateTime?

But I agree that it's confusing, particularly because empty sequences
just disappear when you create a sequence that includes them. That's
where if-absent() is going to come in handy, I think.

Using if-absent() in this example:

  <xsl:value-of select="for $e in ancestor::node()
                            return if-absent(name($e), '')"
                separator="/" />

[I worry about if-absent() though - don't the arguments against having
if as a function apply to the if-absent() function as well (i.e. you
might not want the second argument to be evaluated)?]

The sum() function is an example where, I agree, it just seems
unnecessary, since 0 is a sensible alternative. I guess that the
argument is that if you get back 0 then you don't know whether that's
because there were no items to sum or because they actually summed to
0. But you can always check the number of items in the sequence
separately, and it seems to me that the number of times that you need
to make the distinction is far less than the number of times when the
distinction really doesn't matter.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.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.