[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Get to 2 max values and element names

Subject: Re: [xsl] Get to 2 max values and element names
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 11 May 2012 17:24:27 -0400


I believe MSXML has a node-set() extension (indeed it was an early processor to demonstrate it), so Michael's code in this thread may suggest a way forward.

Note that you will have to do a little extra work, since the code as given appears to assume transparent (i.e. traversible) result tree fragments -- such as you have in a 2.0 processor. They would have to be made into honest XSLT 1.0 node sets, but if you're lucky, he's done most of the hard work for you. :-)


On 5/11/2012 2:58 PM, W Charlton wrote:

I thought temporary trees would come up. This transform is actually done in two stages so that is possible and is possibly the way I will go using xsl's sort-by which would be the obvious route I guess. I was trying to avoid putting too much math(s) in the first transform as the first xsl is reused elsewhere.

We actually take some source data and transform it into a standard format and then do a second transform which is where I need to use the 4 values to do some other stuff; along the lines of:

		<xsl:when test="(PenultValue div TopValue)&gt; 0.3">
			<xsl:text>In this test</xsl:text>
			<xsl:value-of select="TopName"/>
			<xsl:text>  was over 30% more effective than</xsl:text>
			<xsl:value-of select="PenultName"/>
		<xsl:when test="(PenultValue div TopValue)&gt; 0.5">
			<xsl:text>In this test</xsl:text>
			<xsl:value-of select="TopName"/>
			<xsl:text>  was over twice as effective as</xsl:text>
			<xsl:value-of select="PenultName"/>
		... You get the idea

We COULD also interrupt the second or even intercept the data before the first transform and poke the data into SQL and spit it out again and inject our 4 elements. But I was curious to know if there was some way known of doing this with recursion or keys or something, completely in XSLT (1) using MSXML ;).
Extension functions could also be used if need be.

For information the modifiers are hard coded so that if<Modifier/> = x then the four values are set as in:

When the Modifier = 1, the 4 Modifying vars are:
vSteveMod = 1.62
vHelenMod = 2.65
vJackMod = 0.34
vPetraMod = 1.3

When the Modifier = 2, the 4 Modifying vars are:
vSteveMod = 3.85
vHelenMod = 0.89
vJackMod = 6.5
vPetraMod = 14.6

When the Modifier = 1, the 4 Modifying vars are:
vSteveMod = 0.05
vHelenMod = 0.22
vJackMod = 0.22
vPetraMod = 2.85
Mathematically random

You have the whole weekend, make it a good one.

William Charlton
The yMonda team
yMonda Limited
w: www.ymonda.net

-----Original Message----- From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx] Sent: 11 May 2012 16:34 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Get to 2 max values and element names


On 5/11/2012 9:36 AM, W Charlton wrote:
All using XSLT1

Your requirements more or less demand the use of temporary trees and pipelining. Can you use at least use a node-set() extension function, or would you be forced to pipeline on the file system?

XSLT 1.0 was explicitly not designed for this sort of transformation.

In XSLT 2.0, it would be a fun little problem (for those who consider
such little problems fun).


-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread