[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to sort attributes to find min and max?
It has been basically answered previously, but I wanted to test the
beauty of Kernow's XSLT playground feature and also train a little
bit xsl:function. So with XSLT 2.0 you could create
<xsl:function name="f:extreme" as="xs:integer"> <xsl:param name="context"/> <xsl:param name="mode"/> <xsl:param name="label"/> <xsl:variable name="order" select="if ($mode = 'min') then 'ascending' else 'descending'"/> <xsl:for-each select="$context/*[@label=$label]"> <xsl:sort select="@time" data-type="number" order="{$order}"/> <xsl:if test="position() = 1"> <xsl:value-of select="@time"/> </xsl:if> </xsl:for-each> </xsl:function> The results can then be retrieved using calls like: <xsl:value-of select="f:extreme(., 'min', 'Init')"/> <xsl:value-of select="f:extreme(., 'max', 'Init')"/> - Michael PS: I am sure one could spend less lines. Am 22.03.2008 um 03:28 schrieb Z W: Hi
|
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
|