[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: calculating the length ??

Subject: RE: calculating the length ??
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Tue, 13 Mar 2001 10:19:01 -0000
select where length is
> 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.