Subject: Re: [xsl] Preferred declarative approach for outputting tallies based on complex triggers From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 10 Apr 2014 13:00:19 +0100 |
After I wrote that post I realized that, in some sense, I might be asking the wrong question... Might one claim that if I'm still talking about "state variables" and the like that I'm not really embracing the declarative paradigm anyway?
Well quite I was going to ask what you mean by "declarative/non-declarative and "updating state variables" in an XSLT system.
Perhaps I should be asking myself "How do I do the analysis I want to do without resorting to a subsystem of triggers and state functions?"
I suppose one step in that direction would be to reduce dependence on triggers (at least) by using different values for the @mode attribute. Perhaps this would extend to reducing the number of state variables in general that I kept track of.
To give a specific example question, consider a source with the following format:
<items> <item id="31" value="3"/> <item id="21" value="1"/> .... </items>
Each <item> element has an @id and an @value. There can be duplicates of both. An example question to answer is: "Given a set of @id values, an item is "special" if it has one of the @ids in this set AND it is the first such item with that particular @id. Find the subsequence of <items> lying between the first "special" item (if any) and the last special item (if any). For this subsequence, return various values like "how many total items are in the subsequence?" "How many 'special' items are in this subsequence?" "What is the average @value for all items in this subsequene? What is the average @value for the 'special' values? ...
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)"/>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Preferred declarative app, David Rudel | Thread | Re: [xsl] Preferred declarative app, David Rudel |
Re: [xsl] Preferred declarative app, David Rudel | Date | Re: [xsl] Preferred declarative app, David Rudel |
Month |