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

RE: Re: Benefits of xsl.sequence

Subject: RE: Re: Benefits of xsl.sequence
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 30 Sep 2008 09:48:57 +0100
RE:  Re: Benefits of xsl.sequence
> Why is  <xsl:sequence select="$first + $second"/> more 
> efficient than <xsl:value-of select="$first + $second"/>?
> 
> I can understand that math on atomic values ought to be more 
> efficient than math on text nodes, but is the benefits 
> something we can measure in any meaningful sense?

They aren't the same thing, so comparing their efficiency is meaningless.

* One instruction computes a number by adding two numbers. 

* The other computes a number by adding two numbers, converts the result to
a string, and then wraps the string in a text node.

If the latter is what you want to do, then use it. But if you only want the
number, then converting it to a string and wrapping the string in a text
node is a crazy waste of effort, especially if you then convert the result
back to a number, which is something one sees all too often.

Whether you can measure the difference depends entirely of course on how
often you do it. But somehow I think that if the syntax were spelt out in
full as <xsl:create-text-node select="string-join(string($first + $second),
' ')"/> then you wouldn't even consider it. 

You can't claim you are using xsl:value-of rather than xsl:sequence because
it's shorter to write. You're using a complex construct where a simple one
would do, and the only possible reason for that is ingrained habits from
XSLT 1.0.

Michael Kay
http://www.saxonica.com/

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-2007 All Rights Reserved.