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

Re: XSLT 2.0 courses?

Subject: Re: XSLT 2.0 courses?
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 21 Sep 2020 19:51:48 -0000
Re:  XSLT 2.0 courses?
On Mon, 2020-09-21 at 19:18 +0000, Graydon graydon@xxxxxxxxx wrote:
> On Mon, Sep 21, 2020 at 07:06:21PM -0000, Dimitre Novatchev 
> dnovatchev@xxxxxxxxxx scripsit:
> > > B  filter($sequence,$function) => head()
> > 
> > Is there any guarantee that the evaluation of filter() will stop as
> > soon as
> > an initial item is produced?
> I wouldn't think there would be, given that filter() in general is
> specified to filter the whole sequence.

In some cases the expression can be rewritten so that filter() is
replaced by $function(head($sequence)); you can only do this if you
know that $function() won't return an empty sequence though, and
$sequence is known at compile time. BaseX does some rewrites in this
vein, although i don't know if it can ever do this one. Oh kinda:

  filter( (1 to 1000), function($input as xs:integer) { $input * 2 } )
=>  head()

Optimized Query:
head((1 to 1000)[((. mod 2) = 0)])

Similarly, head( (1 to 10000) )
is optimized to 
<QueryPlan compiled="true" updating="false">
  <Int type="xs:integer" size="1">1</Int>

I've used languages that had infinite (OK, uunbounded) sequences as
first class objects, with lazy evaluation, which can be a very natural
way to think about cases like this. But we don't have them :)

It's always hard to know how much optimizing to do in what is
essentially an interpreter - at somep point you can spend so long
optimizing that you end up slower. But if the optimized queries can be
reused in production it's another matter...mmodulo errors!

Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org

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.