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

Re: Preferred declarative approach for outputting tall

Subject: Re: Preferred declarative approach for outputting tallies based on complex triggers
From: David Rudel <fwqhgads@xxxxxxxxx>
Date: Thu, 10 Apr 2014 14:20:00 +0200
Re:  Preferred declarative approach for outputting tall
On Thu, Apr 10, 2014 at 2:00 PM, David Carlisle <davidc@xxxxxxxxx> wrote:

> Well quite I was going to ask what you mean by
> "declarative/non-declarative and "updating state variables" in an XSLT
> system.

Didn't you hear? Michael Kay showed us how to update variables in XSLT
:J (reference to another thread...)

Seriously, I was just referring to using a variable of the same name
in a new scope, as in:
<xsl:next-iteration>
<xsl:param name="var1" select="$new.var1"/>
</xsl:next-iteration>


> I'd do something like something (untested)
>
> <xsl:variable name="sids" select="31,35"/>
> <xsl:variable name="a" select="(item[1],item[@id=$sids][1])[last()]"/>
> <xsl:variable name="b"
> select="(item[last()],item[@id=$sids][last()])[last()]"/>
> <xsl:variable name="s" select="$a|item[$a&lt;&lt;.][.&lt;&lt;$b]|$b"/>
>
> no of items <xsl:value-of select="count($s)"/>
> no of specials <xsl:value-of select="count($s[@id=$sids])/>
> avg  <xsl:value of select="sum($s/@value) div count($s)"/>
>

Thanks, David. I was trying to avoid this approach for performance
considerations. I wanted to do this type of analysis in a single pass.

(Also, I don't think this specific implementation addresses the
possibility that an item with the same @id might show up  multiple
times, and only the first one is "special." So I was expecting this
approach to need something like "for $s in $sids return index-of($s,
$seq/@id)[1]" to retrieve the positions of the special items... this
seemed to me to be quite expensive if there were several such items
and the number of $items is large.

So I was planning on using <xsl:iterate> and keeping track of
information such as:
Have I seen a special item yet? (this is what I mean as a "trigger" as
it signals when to start keeping track of data.)

What $sids have I not seen yet? (This lets me judge whether a given
item is "special" since it is only special the first time.)

What is the sum of all values for @value among items I _know_ to be in
the subsequence I care about.

What is the sum of all values for @value that I have seen since the
last time I saw a special item? (This sum will be added to the above
sum next time I see a special id for the first time.)

And similar information like the above that can then be brought
together at the end to give the results I want in a single pass.

-David

-- 

"A false conclusion, once arrived at and widely accepted is not
dislodged easily, and the less it is understood, the more tenaciously
it is held." - Cantor's Law of Preservation of Ignorance.

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.