Link to home
Create AccountLog in
Avatar of ivan_belal
ivan_belal

asked on

How to properly align rows and columns thru XSLT on blackberry ?

I am trying to display some output ( from sql proc/ email out ) to blackberry. Output is formatted using XSLT. Output has rows and columns. Three columns are numaric, so when numbers vary in digits columns get mis-aligned ( using <xsl:value-of select="format-number(Report/Table3/TOT_MTD,'#####')" />) I have couple of nbsp. Is there a way thru XMLT I can spcify start/end postions or any other way so when digits width vary - spaces are reserved and column alignment sticks. With using <xsl:value-of select="format-number(Report/Table3/TOT_MTD,'000,000.00')" /> works but users do not like leading zeros. Any ideas!
Avatar of BigRat
BigRat
Flag of France image

I presume you are outputting the data in HTML? If so a simple ALIGN=RIGHT on the TD element should do it?
Avatar of ivan_belal
ivan_belal

ASKER

Output is aligned when viewed in MS Outlook. Same email when viewd in a Blackberry table (rows/columns) does not stick in terms of alignment. I have right on TD. As mentioned I was ok with padding with leading zeros, but users did not like it. Help, thanks.
</td>
                  <td style="text-align:right;">
                        <xsl:value-of select="format-number(Report/Table5/TOT_YTD_MF,'#####', 'us')" />
                        <xsl:text disable-output-escaping="yes"></xsl:text>
                  </td>
It might be that blackberry does not support full CSS style sheeting (style="text-align:right") but the old HTML style. It won't do any harm, just add align=right to the TD element and try that.
thank you. no luck. attached is my code for your review.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
	<head>
		<title> sales for <xsl:value-of select="Report/Table1/RPT_DATE"/></title>
	</head>
	<body>
		<p>
			<b>(Dly in 000's)</b>  
		<br/>
		<b>(MTD, YTD in mil's)</b>
		</p>
		<br/>
		<p>
			<b>All products sales</b></p>
	
		<table>
			<tr bgcolor="#AAAAAA">
		    	<td>
					<b>Act</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
				<td ALIGN="right">
					<b>Dly</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
				<td ALIGN="right">
					
					<b>MTD</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
				<td ALIGN="right">
					<b>YTD</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
			</tr>
 
			<xsl:apply-templates select="Report/Table2">
			</xsl:apply-templates>
		</table>
 
 
		<tr>
			<td>
				<b>Total</b>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
 
				<xsl:value-of select="format-number(Report/Table3/TOT_DLY,'#####', 'us')"/>
 
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
 
				<xsl:value-of select="format-number(Report/Table3/TOT_MTD,'#####', 'us')" />
 
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
 
				<xsl:value-of select="format-number(Report/Table3/TOT_YTD,'#####', 'us')" />
 
				<xsl:text disable-output-escaping="yes"></xsl:text>
			</td>
		</tr>
		<br/>
		<p>
			<b>MF sales</b>
		</p>
		<br/>
		<table>
			<tr bgcolor="#AAAAAA">
				<td>
					<b>Act</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
				<td ALIGN="right">
					<b>Dly</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
				<td ALIGN="right">
					<b>MTD</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
				<td ALIGN="right">
					<b>YTD</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
			</tr>
			<xsl:apply-templates select="Report/Table4">
			</xsl:apply-templates>
		</table>
 
 
		<tr>
			<td>
				<b>Total</b>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(Report/Table5/TOT_DLY_MF,'#####', 'us')" />
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(Report/Table5/TOT_MTD_MF,'#####', 'us')" />
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(Report/Table5/TOT_YTD_MF,'#####', 'us')" />
				<xsl:text disable-output-escaping="yes"></xsl:text>
			</td>
		</tr>
		<br/>
		<p>
			<b>SMA sales</b>
			<br/>
		</p>
		<table>
			<tr bgcolor="#AAAAAA">
				<td>
					<b>Act</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
				<td ALIGN="right">
					<b>Dly</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
				<td ALIGN="right">
					<b>MTD</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
				<td ALIGN="right">
					<b>YTD</b>
					<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
				</td>
			</tr>
			<xsl:apply-templates select="Report/Table6">
			</xsl:apply-templates>
		</table>
 
 
		<tr>
			<td>
				<b>Total</b>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(Report/Table7/TOT_DLY_SMA,'#####', 'us')" />
				<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(Report/Table7/TOT_MTD_SMA,'#####', 'us')" />
				<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(Report/Table7/TOT_YTD_SMA,'#####', 'us')" />
				<xsl:text disable-output-escaping="yes"></xsl:text>
			</td>
		</tr>
 
				
		
	</body>
	
</html>
</xsl:template>
	<xsl:decimal-format name="us" decimal-separator='.' grouping-separator=',' />
	
	<xsl:template match="Report/Table2">
		<tr>
			<xsl:if test="position() mod 2 = 0">
				<xsl:attribute name="bgcolor">#AAAAAA</xsl:attribute>
			</xsl:if>
			<xsl:if test="position() mod 2 = 1">
				<xsl:attribute name="bgcolor">#EEEEEE</xsl:attribute>
			</xsl:if>
 
			<td>
				<xsl:value-of select="F_NM"/>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
 
				<xsl:value-of select="format-number(DLY,'#####', 'us')"/>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
 
				<xsl:value-of select="format-number(MTD,'#####', 'us')"/>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
 
				<xsl:value-of select="format-number(YTD,'#####', 'us')"/>
				<xsl:text disable-output-escaping="yes"></xsl:text>
			</td>
 
		</tr>
	</xsl:template>
 
	<xsl:template match="Report/Table4">
		<tr>
			<xsl:if test="position() mod 2 = 0">
				<xsl:attribute name="bgcolor">#AAAAAA</xsl:attribute>
			</xsl:if>
			<xsl:if test="position() mod 2 = 1">
				<xsl:attribute name="bgcolor">#EEEEEE</xsl:attribute>
			</xsl:if>
 
			<td>
				<xsl:value-of select="F_NM"/>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(DLY_MF,'#####', 'us')"/>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(MTD_MF,'#####', 'us')"/>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(YTD_MF,'#####', 'us')"/>
				<xsl:text disable-output-escaping="yes"></xsl:text>
			</td>
 
		</tr>
	</xsl:template>
 
	<xsl:template match="Report/Table6">
		<tr>
			<xsl:if test="position() mod 2 = 0">
				<xsl:attribute name="bgcolor">#AAAAAA</xsl:attribute>
			</xsl:if>
			<xsl:if test="position() mod 2 = 1">
				<xsl:attribute name="bgcolor">#EEEEEE</xsl:attribute>
			</xsl:if>
 
			<td>
				<xsl:value-of select="F_NM"/>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(DLY_SMA,'#####', 'us')"/>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(MTD_SMA,'#####', 'us')"/>
				<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
			</td>
			<td ALIGN="right">
				<xsl:value-of select="format-number(YTD_SMA,'#####', 'us')"/>
				<xsl:text disable-output-escaping="yes"></xsl:text>
			</td>
 
		</tr>
		
	</xsl:template>
	
</xsl:stylesheet>
 
  

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of BigRat
BigRat
Flag of France image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Input comes out of a Sql proc. Do not have an XML, but you can visualize or even make a sample test XML yourself if works. Basically four columns. Three of them numaric. First column is text. Any help is appreciated.