RSS 2.0
Sign In
# Saturday, 30 August 2008

I was already writing about tuples and maps in the xslt (see Tuples and maps - Status: CLOSED, WONTFIX, and Tuples and maps in Saxon).

Now, I want to argue on a use case, and on how xslt processor can detect such a use case and implement it as map. This way, for a certain conditions, a sequences could be treated as maps (or as sets).

Use case.

There are two stages:

  • a logic collecting nodes/values satisfying some criteria.
  • process data, and take a special action whenever a node/value is collected on the previous stage.

Whenever we're talking of nodes than result of the first stage is a sequence $set as node()*. The role of this sequence is a set of nodes (order is not important).

The second stage is usually an xsl:for-each, an xsl:apply-templates, or something of this kind, which repeatedly verifies whether a some $node as node()? belongs to the $set, like a following: $node intersect $set, or $node except $set.

In spite of that we're still using regular xpath 2.0, we have managed to express a set based operation. It's a matter of xslt processor's optimizer to detect such a use case and consider a sequence as a set. In fact the detection rule is rather simple.

For expressions $node except $set and $node intersect $set:
  • $set can be considered as a set, as order of elements is not important;
  • chances are good that a $set being implemented as a set outperforms implementation using a list or an array.

Thus what to do? Well, I do not think I'm the smartest child, quite opposite... however it worth to hint this idea to xslt implementers (see Suggest optimization). I still do not know if it was fruitful...

P.S. A very similar use case exists for a function index-of($collection, $item).

Saturday, 30 August 2008 07:44:44 UTC  #    Comments [0] -
xslt
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

[Captcha]Enter the code shown (prevents robots):

Live Comment Preview
Archive
<2008 August>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
Statistics
Total Posts: 387
This Year: 3
This Month: 0
This Week: 0
Comments: 2144
Locations of visitors to this page
Disclaimer
The opinions expressed herein are our own personal opinions and do not represent our employer's view in anyway.

© 2024, Nesterovsky bros
All Content © 2024, Nesterovsky bros
DasBlog theme 'Business' created by Christoph De Baene (delarou)