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

RE: Setting values for variable

Subject: RE: Setting values for variable
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 10 Sep 2004 17:43:29 +0100
RE:  Setting values for variable
> But just to ilustrate how vars should be used,
> 
> 		<xsl:variable name="t1">
> 			<xsl:value-of 
> select="sum(/Trade/Record[Payment]/Payment)" />
> 		</xsl:variable>


Don't use this construct unless you have a very good reason. It's much
better to write:

<xsl:variable name="t1" 
              select="sum(/Trade/Record[Payment]/Payment)" />

Why?

Firstly, it's shorter and more readable.

More importantly, the resulting value is a number, not a result tree
fragment. A number is a much simpler object than a result tree fragment, so
it's cheaper to create and cheaper to access. There are also some contexts,
for example in the predicate P[$t1], where it's important for correct
operation that the value should be a number.

Michael Kay

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.