This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: calculating the length ??
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] calculating the length ??
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Tue, 13 Mar 2001 10:19:01 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
> I hope You can help me solving my problem.
>
> <LIST>
> <ELEMENT lenght="2"/>
> <ELEMENT lenght="10"/>
> <ELEMENT lenght="4"/>
> </LIST>
>
> I would like to know what the max length is for the elements,
There are three solutions:
1: (with O(n^2) performance) is
element[not(../element/@length > @length)]
2: (with O(n log n) performance):
<xsl:for-each select="element">
<xsl:sort select="@length" data-type="number" order="descending"/>
<xsl:if test="position()=1"><xsl:value-of select="@length"/></xsl:if>
</xsl:for-each>
3: (with O(n) performance):
write a recursive named template that processes the list of elements, at
each iteration compare the length of the current element with the max of the
rest of the list.
Mike Kay
Software AG
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list