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

Re: String length question

Subject: Re: String length question
From: Anton Triest <anton@xxxxxxxx>
Date: Fri, 22 Oct 2004 01:25:31 +0200
xsl string length
Marcio Ferreira wrote:

I want to now the sum of the lengths of attribute descriptions in the
xml below

<folder description="Ngin Mart">
    <folder description="Clientes"/>
    <folder description="Desempenho"/>
    <folder description="MyReports">
</folder>

I have tried this:

<xsl:template match="folder mode="left_menu">
   <xsl:variable name="sizeTotal"  select = 'string-length(descendant::folder/@description)'/>
   <table border="0" cellspacing="0" cellpadding="0" width="{count(folder)*$sizeTotal}">
     <tr>
       <xsl:apply-templates select="folder" mode="left_menu"/>
     </tr>
   </table>
 </xsl:template>

The variable "sizeTotal" will be the width of the table.

But dont work.

Hi Marcio,

I think "string-length(descendant::folder/@description)" will only test one description attribute (the first in document order).

Possible solution: first collect all the descriptions inside a variable, then use string-length on that variable:

<xsl:template match="folder" mode="left_menu">
<xsl:variable name="all-descriptions">
<xsl:copy-of select="descendant::folder/@description"/>
</xsl:variable>
<xsl:variable name="sizeTotal" select="string-length($all-descriptions)"/>
...
</xsl:template>

HTH,
Anton

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.