RE: [xsl] xpath 2.0 expressions

Subject: RE: [xsl] xpath 2.0 expressions
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 3 Jan 2002 13:10:51 -0000
> After Mike and Jeni's comments re brevity [complexity?]
> I find it unusual to mandate the else clause in
> the if, then, else.

It's a conditional expression rather than a conditional instruction; with a
conditional instruction, doing nothing in the else branch is a reasonable
default, but with conditional expressions, most languages require both
branches to be explicit. It would certainly be possible to return () (the
empty sequence) if the else branch is omitted, but I don't know whether this
would really be a good idea. In the cases where it's what you want you can
usually rewrite it as a predicate:

Instead of
  for $i in //item return (if (exists($i/@value)) then $i/@value else ())
write
  for $i in //item[@value] return $i/@value

Mike Kay


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


Current Thread