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

Re: converting cals table to html using xslt

Subject: Re: converting cals table to html using xslt
From: "Tech Savvy" <tecsavvy@xxxxxxxxx>
Date: Thu, 4 May 2006 10:26:16 -0500
fo table row colspan
Hi Andrew:

I am outputing to both XHTML and XSL:FO. I need only a subset of the
cals table implemented. The two features I describe below are critical
and have to be implemented. I am not sure how to start it. Her eis a
snippet of the transformation that I have written for the table: This
does not include colwidth and namest.

For XSL:FO:
-----------------------------------------------------------------------------
-----------------------------
<xsl:template match="table">

<fo:block space-before="6pt" space-before.conditionality="retain">

			<xsl:apply-templates select="tgroup"/>
		</fo:block>

		<fo:block space-before="6pt" space-before.conditionality="retain"/>
	</xsl:template>
	<xsl:template match="tgroup">
		<fo:table keep-together.within-page="always" text-align="left"
border="1pt solid black">
			<xsl:call-template name="set_columns">
				<xsl:with-param name="count" select="@cols"/>
				<xsl:with-param name="columns" select="@cols"/>
			</xsl:call-template>
			<fo:table-header>
				<fo:table-row line-height="12pt" font-size="11pt"
font-weight="bold" background-color="#FFFFFF">
					<xsl:apply-templates select="colspec"/>
				</fo:table-row>
			</fo:table-header>
			<xsl:apply-templates select="thead"/>
			<xsl:apply-templates select="tbody"/>
		</fo:table>
	</xsl:template>
	<xsl:template match="colspec">
		<fo:table-cell border-right-style="solid"
border-bottom-style="solid" border-width="1pt"
border-right-color="white" padding-start="4pt" padding-top="3pt"
padding-bottom="3pt" display-align="before">
			<fo:block>
				<fo:inline color="white">
					<xsl:value-of select="@colname"/>
				</fo:inline>
			</fo:block>
		</fo:table-cell>
	</xsl:template>
	<xsl:template match="thead">
		<fo:table-body>
			<xsl:apply-templates select="row"/>
		</fo:table-body>
	</xsl:template>
	<xsl:template match="tbody">
		<fo:table-body>
			<xsl:apply-templates select="row"/>
		</fo:table-body>
	</xsl:template>
	<xsl:template match="row">
		<fo:table-row line-height="12pt" font-size="11pt"
background-color="#FFFFFF">
			<xsl:apply-templates select="entry/text/para"/>
		</fo:table-row>
	</xsl:template>
	<xsl:template match="entry/text/para">
		<fo:table-cell start-indent="0pt" text-align="left"
border-width="1pt" padding-top="3pt" padding-bottom="3pt"
border-top-style="solid" border-bottom-style="solid"
border-right-style="solid" border-left-style="solid">
			<xsl:apply-templates select="line"/>
			<xsl:if test="not(line)">
				<fo:block text-align="left">
					<xsl:apply-templates/>
				</fo:block>
			</xsl:if>
		</fo:table-cell>
	</xsl:template>
	<xsl:template name="set_columns">
		<xsl:param name="count"/>
		<xsl:param name="columns"/>
		<xsl:if test="$count !=0">
			<xsl:call-template name="set_columns">
				<xsl:with-param name="count" select="$count -1"/>
				<xsl:with-param name="columns" select="$columns"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

-----------------------------------------------------------------------------
For XHTML:

<xsl:template match="table">
		<table align="center" width="90%" border="1pt solid black">
			<xsl:apply-templates/>
		</table>
	</xsl:template>

<xsl:template match="tbody">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="row">
		<TR>
			<xsl:apply-templates/>
		</TR>
	</xsl:template>

<xsl:template match="entry">

<TD>

			<xsl:apply-templates/>
		</TD>
	</xsl:template>
	<xsl:template match="thead/row/entry/text/para">
		<br/>
		<th align="center" valign="top" rowspan="0.5" colspan="1" nowrap="nowrap">
			<P>
				<xsl:apply-templates/>
			</P>
		</th>
	</xsl:template>
	<xsl:template match="row">
		<TR align="left" valign="top">
			<P>
				<xsl:apply-templates/>
			</P>
		</TR>
	</xsl:template>
	<xsl:template match="thead">
		<xsl:element name="{name(.)}">
			<xsl:if test="@align">
				<xsl:attribute name="align"><xsl:value-of
select="@align"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="@char">
				<xsl:attribute name="char"><xsl:value-of select="@char"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="@charoff">
				<xsl:attribute name="charoff"><xsl:value-of
select="@charoff"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="@valign">
				<xsl:attribute name="valign"><xsl:value-of
select="@valign"/></xsl:attribute>
			</xsl:if>
		</xsl:element>
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="tbody">
		<tbody>
			<xsl:if test="@align">
				<xsl:attribute name="align"><xsl:value-of
select="@align"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="@char">
				<xsl:attribute name="char"><xsl:value-of select="@char"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="@charoff">
				<xsl:attribute name="charoff"><xsl:value-of
select="@charoff"/></xsl:attribute>
			</xsl:if>
			<xsl:if test="@valign">
				<xsl:attribute name="valign"><xsl:value-of
select="@valign"/></xsl:attribute>
			</xsl:if>
			<xsl:apply-templates/>
		</tbody>
	</xsl:template>



On 5/4/06, andrew welch <andrew.j.welch@xxxxxxxxx> wrote:
On 5/4/06, Tech Savvy <tecsavvy@xxxxxxxxx> wrote:
> Hi:
>
> I did look at the archive and at all the examples. I am actually
> having a hard time  implementing the cals table solution.
>
> Here is what I need to do:
> 1) I have a table which is in cals table format:
>
> <table>
> <tgroup cols="5">
> <colspec colname="c1" colwidth="1.35in">
>  </colspec>
> <colspec colname="c2" colwidth="1in">
>  </colspec>
> <colspec colname="c3" colwidth="0.75in">
>  </colspec>
> <colspec colname="c4" colwidth="1in">
>  </colspec>
> <colspec colname="c5" colwidth="0.9in">
>  </colspec>
> <tbody>
>      <row>
>           <entry nameend="4" namest="c3">
>                    <text>
>                               <para> Text1 </para>
>                     </text>
>           </entry>
>      </row>
> </tbody>
> </tgroup>
> </table>
>
> I need a style sheet (xslt and xslfo) in which
> 1)the <td> width is set to the colwidth of cals table and
> 2) I need to know how to handle nameest and nameend on the style
> sheet. My understanding is that this defines the col span. Is that a
> correct understanding? If so, the "text1" should span two columns.

Implementing a cals table stylesheet is no mean feat, and you seem to
be at the very early stages.  I would get your problem defined first -
do you need to implement the whole of cals or a subset?  Are you
outputting to both XHTML and XSL:FO?  It could be sufficient to use
the Oasis table stylesheets in docbook.

It's a massive task as the cals standard is so loose - its certainly
not something to undertake lightly.  For example, in some
circumstances to correctly work out the row and col spans you need to
normlize the table first - possible but pretty much a nightmare.  I
don't think there's a stylesheet out there that fully implements the
spec.

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.