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

Re: to extract the longest string (fwd)

Subject: Re: to extract the longest string (fwd)
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 18 Aug 2000 11:14:39 +0200 (MET DST)
extract of oliver
Hi,

> I want to concatnate the 'align' attributes of the <col> under each 
> <row>  into  separate strings and after that I want to extract the
> lengthiest of the strings.
> 
> For example first <col> attributes gives "ll"
> 	    second <col> attribute gives  "ccc"
> 	    third <col> attribute gives "rrrr"
> 						
> I must get "rrrr" as the output since that is the lengthiest of the
> three string.
> 
> I hope someone will help me with an XSL script.
> 
> <?xml version="1.0"?>
> <table>
> <row>
> 	<col align="l"/>
> 	<col align="l"/>
> </row>
> <row>
> 	<col align="c"/>
> 	<col align="c"/>
> 	<col align="c"/>
> </row>
> <row>
> 	<col align="r"/>
> 	<col align="r"/>
> 	<col align="r"/>
> 	<col align="r"/>
> </row>
> </table>

The following works similar to a solution recently posted by Jeni:

<xsl:template match="table">
   <xsl:for-each select="row">
      <xsl:sort select="count(col)" 
                data-type="number" order="descending" />
      <xsl:if test="position()=1">
         <xsl:for-each select="col">
            <xsl:value-of select="@align" />
         </xsl:for-each>
      </xsl:if>
   </xsl:for-each>
</xsl:template>

Note: it does not exactly what you describe.
It selects the row with the biggest number of cols and then
concatenates all the values of the align attribute.
Since they are all of length 1, the result will be the expected "rrrr".

Regards,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


 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-2011 All Rights Reserved.