[xsl] Table <br/> conversion

Subject: [xsl] Table <br/> conversion
From: Aaron Lim <yuchoong@xxxxxxxxx>
Date: Thu, 19 Feb 2004 19:41:31 -0800 (PST)
Do anyone of you know how to enable an item in a table
to go to next line without using <br/>

If you are doing the xsl, if you used 
<xsl:value-of select="'&#10;'"/> in the table, it
won't works.  It won't go to the next line.

Actually, it is calling a template which will replace
the character ',' in a string to '#10;' so that it
will go to next line.  However, it didn't works.

The actual coding is like below:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xalan="http://xml.apache.org/xalan";
exclude-result-prefixes="xalan" >
<xsl:output method="html" indent="yes"
omit-xml-declaration="yes" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:variable name="myString" select="'first message,
second, third'"/>
  <xsl:variable name="myNewString">
    <xsl:call-template name="replaceCharsInString">
      <xsl:with-param name="stringIn"
select="string($myString)"/>
      <xsl:with-param name="charsIn" select="', '"/>
      <xsl:with-param name="charsOut"
select="'&#10;'"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="myNewRealString"
select="string($myNewString)"/>
 <table width="100%" border="1" cellspacing="0"
cellpadding="0" bordercolor="#000000">
			<tbody>
				<tr>
					<td>
						<xsl:value-of select="$myNewRealString"/>
					</td>
				</tr>
			</tbody>
</table>
</xsl:template>

<xsl:template name="replaceCharsInString">
  <xsl:param name="stringIn"/>
  <xsl:param name="charsIn"/>
  <xsl:param name="charsOut"/>
  <xsl:choose>
    <xsl:when test="contains($stringIn,$charsIn)">
      <xsl:value-of
select="concat(substring-before($stringIn,$charsIn),$charsOut)"/>
      <xsl:call-template name="replaceCharsInString">
        <xsl:with-param name="stringIn"
select="substring-after($stringIn,$charsIn)"/>
        <xsl:with-param name="charsIn"
select="$charsIn"/>
        <xsl:with-param name="charsOut"
select="$charsOut"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$stringIn"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>

Ok.  Hope to get the quick reply from you!!

Thanks a lot.


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread