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

Re: Cheaper to prepend or append an item to a sequence

Subject: Re: Cheaper to prepend or append an item to a sequence?
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 22 Feb 2011 11:56:31 +0000
Re:  Cheaper to prepend or append an item to a sequence
On 22 February 2011 11:27, Costello, Roger L. <costello@xxxxxxxxx> wrote:
> Hi Folks,
>
> When adding an item to a sequence, it is: (circle the correct answer)
>
> (a) Cheaper to add the item to the front of the sequence
>
> (b) Cheaper to add the item to the end of the sequence
>
> (c) Costs the same to add the item to the front or to the end
>
> (d) The cost varies depending on the XSLT processor


Well, an item isnt really added to existing sequence, an new sequence
is created from the old one plus the new item... so ultimately it
might be best to create the larger sequence in the first place, then
get the smaller sequence using subsequence()...

I know you are after a theoretical answer but in practice that sort of
thing is rarely a big cost.  The best tip here is, if you are only
using the values of the nodes, then use a sequence of atomics instead
of nodes.  For example:

<item>1</item>
<item>2</item>
<item>3</item>

instead of:

<xsl:variable name="items" select="/path/to/item">

do

<xsl:variable name="items" select="/path/to/item/xs:integer(.)"
as="xs:integer+"/>



-- 
Andrew Welch
http://andrewjwelch.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-2013 All Rights Reserved.