|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: how to get maximum, minimum values of an element u
Hi again Anand,
> i am using XSLT for transsormation and i want to show the maximum ,
> minuimum values of SessionSartupTime , PageTime etc using XSLT...how
> can i do that ??
Three ways:
1. Through an XPath: select the SessionStartupTime for which there is
no higher (or lower) value:
JartaXmlReport[not(../JartaXmlReport/SessionStartupTime >
SessionStartupTime)]/SessionStartupTime
2. Through a sort-and-pick-first approach, sorting in descending (or
ascending) order:
<xsl:for-each select="JartaXmlReport">
<xsl:sort select="SessionStartupTime" data-type="number"
orders="descending" />
<xsl:if test="position() = 1">
<xsl:value-of select="SessionStartupTime" />
</xsl:if>
</xsl:for-each>
3. Through a recursive template that walks through from higher to
higher SessionStartupTime. Apply it only to the first JartaXmlReport:
<xsl:apply-templates select="JartaXmlReport[1]" mode="find-max" />
The template is something like:
<xsl:template match="JartaXmlReport" mode="find-max">
<xsl:variable name="next"
select="following-sibling::JartaXmlReport
[SessionStartupTime >
current()/SessionStartupTime]" />
<xsl:choose>
<xsl:when test="$next">
<xsl:apply-templates select="$next" mode="find-max" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="SessionStartupTime" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
The first is generally best for small sets, the second for medium ones
and the third for large ones. You'll need to test it with your
particular source XML to find which works best for you.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








