Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2010, 11:56 AM
blg blg is offline
Registered User
 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Controlling Table width and column width

Here is additional info:
I am new to XSLT and XSL-FO. I am trying to include mark-up to format the width of columns in tables in an XML document. I want the tables to import so that they are 18 picas in width. I am working in Windows XP.

Here is sample of input XML:

<table>
<tgroup cols="2" align="left" colsep="1" rowsep="1">
<colspec colname="c1"></colspec>
<colspec colname="c2"></colspec>
<tbody>
<row><tabletext colspan="2">This is sample table title.</tabletext></row>
<row><columnhead>Col 1</columnhead><columnhead>Col 2</columnhead></row>
<row><tabletext>Core Broad Market Composite Assets</tabletext><tablenumber>$5.1 billion</tablenumber></row>
<row><tabletext>Effective Duration</tabletext><tablenumber>3.61 Years</tablenumber></row>
<row><tabletext>Effective Maturity</tabletext><tablenumber>4.75 Years</tablenumber></row>
<row><tabletext>Convexity</tabletext><tablenumber>0.06</tablenumber></row>
<row><tabletext>Yield-to-Maturity</tabletext><tablenumber>3.94%</tablenumber></row>
<row><tabletext>Average Quality</tabletext><tablenumber>Aa3</tablenumber></row>
<row><tabletext>Turnover (12-Month Rolling)</tabletext><tablenumber>33%</tablenumber></row>
</tbody>
</tgroup>
</table>
<bodycopy><emphasis role="italic">Index: Barclays Aggregate Index</emphasis></bodycopy>

<table>
<tgroup cols="3" align="left" colsep="0" rowsep="0">
<colspec colname="c1"></colspec>
<colspec colname="c2"></colspec>
<colspec colname="c3"></colspec>


<tbody>
<row><tabletext colspan="3">5-Year Statistics vs. Benchmark</tabletext></row>

<row><columnhead></columnhead><columnhead>Strategy</columnhead><columnhead>Index</columnhead></row>

<row><tabletext>Standard Deviation</tabletext><tablenumber>3.84</tablenumber><tablenumber>3.57</tablenumber></row>
<row><tabletext>Sharpe Ratio</tabletext><tablenumber>0.68</tablenumber><tablenumber>0.54</tablenumber></row>
<row><tabletext>Tracking Error</tabletext><tablenumber>1.67</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Treynor Ratio</tabletext><tablenumber>2.68</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Information Ratio</tabletext><tablenumber>0.39</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Alpha</tabletext><tablenumber>0.82</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Beta</tabletext><tablenumber>0.97</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Correlation</tabletext><tablenumber>0.9</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Rsquared</tabletext><tablenumber>0.81</tablenumber><tablenumber>N/A</tablenumber></row>

</tbody>
</tgroup>
</table>

This XML file is being imported into Framemaker using an automated process.

The XSL mark-up looks like this:
<!-- Table elements -->
<xsl:template match="table">

<xsl:copy>

<xsl:apply-templates/>
</xsl:copy>
</xsl:template>


<xsl:template match="tgroupsingle">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="tgroup">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>


<xsl:template match="colspec">

<xsl:copy>

<xsl:for-each select="@*">

<xsl:copy/>
</xsl:for-each>

<xsl:apply-templates/>

</xsl:copy>

</xsl:template>

<xsl:template match="tbody">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="row">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="columnhead">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="tablehead">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="tabletext">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="tablenumber">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>

</xsl:template>

How do I markup the xsl so that the table width is 18 picas?
Here is additional info:
I am new to XSLT and XSL-FO. I am trying to include mark-up to format the width of columns in tables in an XML document. I want the tables to import so that they are 18 picas in width. I am working in Windows XP.

Here is sample of input XML:

<table>
<tgroup cols="2" align="left" colsep="1" rowsep="1">
<colspec colname="c1"></colspec>
<colspec colname="c2"></colspec>
<tbody>
<row><tabletext colspan="2">This is sample table title.</tabletext></row>
<row><columnhead>Col 1</columnhead><columnhead>Col 2</columnhead></row>
<row><tabletext>Core Broad Market Composite Assets</tabletext><tablenumber>$5.1 billion</tablenumber></row>
<row><tabletext>Effective Duration</tabletext><tablenumber>3.61 Years</tablenumber></row>
<row><tabletext>Effective Maturity</tabletext><tablenumber>4.75 Years</tablenumber></row>
<row><tabletext>Convexity</tabletext><tablenumber>0.06</tablenumber></row>
<row><tabletext>Yield-to-Maturity</tabletext><tablenumber>3.94%</tablenumber></row>
<row><tabletext>Average Quality</tabletext><tablenumber>Aa3</tablenumber></row>
<row><tabletext>Turnover (12-Month Rolling)</tabletext><tablenumber>33%</tablenumber></row>
</tbody>
</tgroup>
</table>
<bodycopy><emphasis role="italic">Index: Barclays Aggregate Index</emphasis></bodycopy>

<table>
<tgroup cols="3" align="left" colsep="0" rowsep="0">
<colspec colname="c1"></colspec>
<colspec colname="c2"></colspec>
<colspec colname="c3"></colspec>


<tbody>
<row><tabletext colspan="3">5-Year Statistics vs. Benchmark</tabletext></row>

<row><columnhead></columnhead><columnhead>Strategy</columnhead><columnhead>Index</columnhead></row>

<row><tabletext>Standard Deviation</tabletext><tablenumber>3.84</tablenumber><tablenumber>3.57</tablenumber></row>
<row><tabletext>Sharpe Ratio</tabletext><tablenumber>0.68</tablenumber><tablenumber>0.54</tablenumber></row>
<row><tabletext>Tracking Error</tabletext><tablenumber>1.67</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Treynor Ratio</tabletext><tablenumber>2.68</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Information Ratio</tabletext><tablenumber>0.39</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Alpha</tabletext><tablenumber>0.82</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Beta</tabletext><tablenumber>0.97</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Correlation</tabletext><tablenumber>0.9</tablenumber><tablenumber>N/A</tablenumber></row>
<row><tabletext>Rsquared</tabletext><tablenumber>0.81</tablenumber><tablenumber>N/A</tablenumber></row>

</tbody>
</tgroup>
</table>

This XML file is being imported into Framemaker using an automated process.

The XSL mark-up looks like this:
<!-- Table elements -->
<xsl:template match="table">

<xsl:copy>

<xsl:apply-templates/>
</xsl:copy>
</xsl:template>


<xsl:template match="tgroupsingle">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="tgroup">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>


<xsl:template match="colspec">

<xsl:copy>

<xsl:for-each select="@*">

<xsl:copy/>
</xsl:for-each>

<xsl:apply-templates/>

</xsl:copy>

</xsl:template>

<xsl:template match="tbody">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="row">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="columnhead">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="tablehead">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="tabletext">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="tablenumber">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:copy/>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>

</xsl:template>

How do I markup the xsl so that the table width is 18 picas?
 
Old April 1st, 2010, 11:59 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I don't know how you do that - how about you let us know what you want the output XML to look like and we might be able to help you.

Something like this perhaps?

<colspec colwidth="18picas"/>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old April 1st, 2010, 12:03 PM
blg blg is offline
Registered User
 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I want tables with 2 and 3 columns to display. For the 2 column tables, I want the first column to be 10 picas wide and the second column 8 picas wide.

For the 3 column tables, I want the first column 8 picas wide and the other 2 columns 5 picas wide each.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Max column width in table RickoT HTML Code Clinic 2 November 29th, 2006 08:16 AM
Controlling width of fields in a subform HowardB Access 2 April 13th, 2005 06:50 AM
Column width immanuelsamuel Oracle 2 March 13th, 2004 10:30 AM
Fix table column width?? Snib HTML Code Clinic 2 January 4th, 2004 03:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.