RE: [xsl] How to make tables using XSL

Subject: RE: [xsl] How to make tables using XSL
From: "Norma Yeazell" <Nyeazell@xxxxxxxxx>
Date: Fri, 2 Apr 2004 14:23:49 -0500
 Here's what I use for generic tables you may have to change a few
things

<!-- beginning of table elements -->

<xsl:template match="table">
    <fo:table-and-caption id="{@id}" caption-side="before"
space-after="4mm">
        <fo:table-caption space-after="2mm">
            <fo:block text-align="center" font-style="italic"
keep-with-next.within-page="always" start-indent="0em">
            <fo:marker marker-class-name="issue-table-header"/>
            <xsl:text>Table </xsl:text>
            <xsl:number count="table|table-and-caption" from="dmodule"
level="any"/>
            <xsl:text>  </xsl:text>
                <xsl:apply-templates select="title" mode="make-title"/>
            </fo:block>
    </fo:table-caption>
        <fo:table margin-left="2cm" table-layout="fixed"
inline-progression-dimension="15cm" border-before-style="solid"
border-before-width="0.5pt" border-after-style="solid"
border-after-width="0.5pt">
            <xsl:apply-templates/>
        </fo:table>
    </fo:table-and-caption>
</xsl:template>

<xsl:template match="table/title">
</xsl:template>

<xsl:template match="tgroup">
<fo:table-column column-number="{@cols}"/>
    <xsl:apply-templates select="tbody|thead"/>
</xsl:template>

<xsl:template match="col">
</xsl:template>

<xsl:template match="thead">
<fo:table-header display-align="center" border-collapse="collapse"
border-before-style="solid" border-before-width="0.5pt"
border-after-style="solid" border-after-width="0.5pt">
    <xsl:apply-templates/>
</fo:table-header>
</xsl:template>

<xsl:template match="tfoot">
<fo:table-footer>
    <xsl:apply-templates/>
</fo:table-footer>
</xsl:template>

<xsl:template match="tbody">
<fo:table-body>
    <fo:table-row height="2mm"><fo:table-cell width="15cm"
span="all"/></fo:table-row>
        <xsl:apply-templates/>
    <fo:table-row height="2mm">
        <fo:table-cell>
            <fo:marker marker-class-name="issue-table-header">
                <fo:block space-before="1mm" text-align="center"
font-style="italic" keep-with-next.within-page="always"
start-indent="0em">
                    <xsl:text>Table </xsl:text>
                    <xsl:number count="table|table-and-caption"
from="dmodule" level="any"/>
                    <xsl:text>  </xsl:text>
                    <xsl:value-of select="//table/title"/>
                    <xsl:text> (Continued)</xsl:text>
                </fo:block>
            </fo:marker>
        </fo:table-cell>
    </fo:table-row>
</fo:table-body>
</xsl:template>

<xsl:template match="thead/row">
<fo:table-row width="15cm">
    <xsl:apply-templates/>
</fo:table-row>
</xsl:template>

<xsl:template match="row">
<fo:table-row width="15cm">
    <xsl:apply-templates/>
</fo:table-row>
</xsl:template>

<xsl:template match="thead/row/entry">
<fo:table-cell>
    <xsl:call-template name="cell-span"/>
        <xsl:if test="@valign">
            <xsl:attribute name="display-align">
                <xsl:value-of select="@valign"/>
            </xsl:attribute>
        </xsl:if>
    <fo:block margin-left="-2cm" text-align="left">
    <xsl:if test="@align">
        <xsl:attribute name="text-align">
            <xsl:value-of select="@align"/>
        </xsl:attribute>
    </xsl:if>
        <xsl:apply-templates/>
    </fo:block>
</fo:table-cell>
</xsl:template>

<xsl:template match="entry">
<fo:table-cell>
    <xsl:call-template name="cell-span"/>
        <xsl:if test="@valign">
            <xsl:attribute name="display-align">
                <xsl:value-of select="@valign"/>
            </xsl:attribute>
        </xsl:if>
    <fo:block text-align="left" margin-left="-2cm">
            <fo:marker marker-class-name="issue-table-header">
                <fo:block space-before="1mm" text-align="center"
font-style="italic" keep-with-next.within-page="always"
start-indent="0em">
                    <xsl:text>Table </xsl:text>
                    <xsl:number count="table|table-and-caption"
from="dmodule" level="any"/>
                    <xsl:text>  </xsl:text>
                    <xsl:value-of select="//table/title"/>
                    <xsl:text> (Continued)</xsl:text>
                </fo:block>
            </fo:marker>
    <xsl:if test="@align">
        <xsl:attribute name="text-align">
            <xsl:value-of select="@align"/>
        </xsl:attribute>
    </xsl:if>
        <xsl:apply-templates/>
    </fo:block>
</fo:table-cell>
</xsl:template>

<xsl:template name="cell-span">
<xsl:if test="@namest">
<xsl:attribute name="number-columns-spanned">
<xsl:value-of select="@nameend"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@namest">
<xsl:attribute name="number-rows-spanned">
<xsl:value-of select="@nameend"/>
</xsl:attribute>
</xsl:if>
</xsl:template>

<xsl:template name="spanspec">
  <fo:wrapper>
    <xsl:apply-templates/>
  </fo:wrapper>
</xsl:template>



<!-- end of table templates -->

-----Original Message-----
From: puja thakral [mailto:puja_thakral@xxxxxxxxx] 
Sent: Friday, April 02, 2004 1:37 PM
To: List; xml
Subject: [xsl] How to make tables using XSL

Hi All,
Can somebody pls tell me how to make tables using XSL and enter the data
cleanly in each cell.In HTML it's fairly simple but I don't have any
ides with XSL.Any help is appreciated a lot.
Thanks,
Puja

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/



Confidentiality Notice
The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you have received this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited.

Current Thread