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

Re: XSLT Table defination Question

Subject: Re: XSLT Table defination Question
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Fri, 21 Jun 2002 00:14:56 +0200
xslt table
Use a recursive template:

<xsl:template match="element-with-text">
  <xsl:call-template name="chars">
    <xsl:with-param name="string" select="normalize-space()"/>
  </xsl:call-template>
</xsl:template>

<xsl:template name="chars">
  <xsl:param name="string" select="''"/>
  <xsl:param name="number-of-chars" select="20"/>
  <xsl:value-of select="substring($string, 1, 20)"/>-<br/>
  <xsl:if test="string-length($string) > 20">
    <xsl:call-template name="chars">
      <xsl:with-param name="string" select="substring($string, 21)"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

(untested)

Regards,

Joerg


Mehul Kishor Mehta wrote:
Hello,

I have question about XSLT. I have table with many columns. I want to restrict one of the table column no bigger that say 20 characters. But the problem is value I am putting in from XML file may have words which are longer than 20 characters and so table goes wide... !
e.g if the word is testverylongstringgreaterthantwentychar .
What happens is table goes wider.. and don't restrict it to 20 characters and rest show in next row..
I would like to have output something as follows..
testverylongstringic-
hgreaterthantwentych-
ar


Here is the sample of table defination within XSLT

<TABLE BORDER="true" CELLSPACING="1" CELLPADDING="4" WIDTH="98%">
    <TR>
        <TD WIDTH="20%" VALIGN="TOP" BGCOLOR="#66cccc" HEIGHT="10">
            <B><center>
                <FONT SIZE="2">
                    Attribute Name
                </FONT>
            </center></B>
        </TD>
</TABLE>

Do anyone know anyway I can do what I need ? I would be more than happy even if you point me to right place (if you know) for the question I have.

Thanks a lot for your help,
Mehul.


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.