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

Re: Where is the benefit ? (Was : RE: The hard cocktai

Subject: Re: Where is the benefit ? (Was : RE: The hard cocktail of sequence and (node-)set ..)
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 4 Jan 2002 23:59:36 +0000
benefit generate id
Kevin Jones wrote:
> Having had a quick look through the new specs I am confused at where
> the real benefit is for the XPath 2.0 changes other than a few extra
> functions. It's easy to see the improvements in XSLT 2.0 but the
> rest is just passing me by. Anyone care to try and pinpoint what is
> going to make XPath2.0 better rather than just different?

There are a few things that I think are really useful.

General Steps:

Now you don't have to use xsl:for-each to change to the relevant
document in order to use a key or ID. You can use the key() or id()
function within an path. For example:

  document('icons.xml')/key('icons', current()/@name)

The same goes for other expressions that return nodes from nodes. For
example, you can get all the headings in an HTML document with:

  //(h1 | h2 | h3 | h4 | h5 | h6)

rather than using something like:

  //*[self::h1 or self::h2 or self::h3 or
      self::h4 or self::h5 or self::h6]

as you have to in XPath 1.0.

Range Expressions:

Rather than using recursive template or the Piez Method to iterate a
certain number of times, you can now create sequences of a certain
length to iterate over. For example, insert five br elements with:

  <xsl:for-each select="(1 to 5)">
    <br />

Node Identity Comparisons:

No more generate-id() = generate-id() or count(.|...) = 1
constructions! Now you can do:

  $node1 == $node2

to test whether two nodes are the same node. Of course the main reason
that we had to use these constructions in the first place was the lack
of grouping support, but nevertheless it's a good thing.

Precedes and Follows Comparisons:

Now you can tell whether one node precedes another within a document
using a simple syntax:

  $node1 << $node2

I can't bring an example to mind right now, but I'm sure there have
been times when I've needed to do that (again, during grouping, I

If Expressions:

Much as I object to keywords, being able to use if/then/else within a
select attribute rather than having an xsl:choose inside a variable,
or using a hideous construction involving concat(), substring() and 1
div 0 is a real godsend :)  For example:

  if (contains($string, $delimiter))
  then substring-before($string, $delimiter)
  otherwise $string

And of course there are the functions:

  - upper-case() and lower-case()
  - match() and replace() (for all they're currently underspecified)
  - min() and max()



Jeni Tennison

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

Current Thread


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.
First Name
Last Name
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.