W3C home > Mailing lists > Public > www-xsl-fo@w3.org > October 2003

Managing Table columns through XSL:FO

From: Girish Kanmas <girishrk@india.ti.com>
Date: Wed, 22 Oct 2003 13:55:44 +0530
To: <www-xsl-fo@w3.org>
Message-ID: <001601c39876$1744e5e0$2653579d@x00nkulk>

Hi,
I am facing problem with subject line of this mail.

Well, I have one XML file and created one xsl file. Below is the listings of
the file:
-----------------------XML FILE---------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href=""?>
<chapter>
	<header name= "Solution Create">
	<columns>8</columns>
		<table 	column1="R1C1"
			column2="R1C2"
			column3="R1C3"
			column4="R1C4"
			column5="R1C5"
			column6="R1C6"
			column7="R1C7"
			column8="R1C8">
		</table>
	</header>
	<header name= "Solution Create">
		<columns>7</columns>
		<table 	column1="R1C1"
			column2="R1C2"
			column3="R1C3"
			column4="R1C4"
			column5="R1C5"
			column6="R1C6"
			column7="R1C7">
		</table>
	</header>
	<header name= "Introduction">
		<columns>6</columns>
		<table 	column1="R1C1S"
			column2="R1C2S"
			column3="R1C3S"
			column4="R1C4S"
			column5="R1C5S"
			column6="R1C6S">
		</table>
	</header>
</chapter>
--------------------------------------
-----------------XSL FILE---------------
<?xml 	version="1.0" 	encoding="UTF-8"?>
<xsl:stylesheet	version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" 	exclude-result-prefixes="fo">
<xsl:output 	method="xml" 	version="1.0" 	omit-xml-declaration="no"
indent="yes"/>
<!-- ========================= -->
<!-- root element: projectteam -->
<!-- ========================= -->
<xsl:template match="chapter">
	<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:layout-master-set>
			<fo:simple-page-master master-name="my-page">
				<fo:region-body margin="1in"/>
			</fo:simple-page-master>
		</fo:layout-master-set>
		<fo:page-sequence master-reference="my-page">

			<fo:flow flow-name="xsl-region-body">
				<xsl:for-each 	select="header">
				<!-- Write the High level details of each Register -->
					<fo:block line-height="0.5in" font-family="Times" font-size="14pt"
font-weight="bold" color="red">
						<xsl:value-of select="@name"/>
					</fo:block>

						<xsl:choose>
						<!-- Greater Than xsl:when test="columns &lt; 4" -->
						<!-- Less Than xsl:when test="columns &gt; 4" -->
						<!-- xsl:when test="columns = 3"-->
						<xsl:when test="columns = 8">
							<fo:table table-layout="fixed">
								<fo:table-column column-width="1.5cm"/>
								<fo:table-column column-width="1.5cm"/>
<fo:table-column column-width="1.5cm"/>
								<fo:table-column column-width="1.5cm"/>
								<fo:table-column column-width="1.5cm"/>
								<fo:table-column column-width="1.5cm"/>
								<fo:table-column column-width="1.5cm"/>
								<fo:table-column column-width="1.5cm"/>
								<fo:table-body>
									<xsl:apply-templates/>
								</fo:table-body>
							</fo:table>
						</xsl:when>
						<xsl:when test="columns = 7">
							<fo:table table-layout="fixed">
								<fo:table-column column-width="1cm"/>
								<fo:table-column column-width="1cm"/>
<fo:table-column column-width="1cm"/>
								<fo:table-column column-width="1cm"/>
								<fo:table-column column-width="1cm"/>
								<fo:table-column column-width="1cm"/>
								<fo:table-column column-width="1cm"/>
								<fo:table-body>
									<xsl:apply-templates/>
								</fo:table-body>
							</fo:table>
						</xsl:when>
						<xsl:otherwise>
							<fo:table table-layout="fixed">
								<fo:table-column column-width="2cm"/>
								<fo:table-column column-width="2cm"/>
								<fo:table-column column-width="2cm"/>
								<fo:table-column column-width="2cm"/>
								<fo:table-column column-width="2cm"/>
								<fo:table-column column-width="2cm"/>
								<fo:table-body>
									<xsl:apply-templates/>
								</fo:table-body>
							</fo:table>
						</xsl:otherwise>
						</xsl:choose>

				</xsl:for-each>
			</fo:flow>
		</fo:page-sequence>
	</fo:root>
</xsl:template>


<xsl:template match="table">

<fo:table-row>
	<fo:table-cell border="0.5pt solid blue">
		<fo:block text-align="center" font-size="9pt" color="green"
font-weight="bold">
			<xsl:value-of select="@column1"/>
		</fo:block>
	</fo:table-cell>
	<fo:table-cell border="0.5pt solid blue">
		<fo:block text-align="center" font-size="9pt" color="green"
font-weight="bold">
			<xsl:value-of select="@column2"/>
		</fo:block>
	</fo:table-cell>
	<fo:table-cell border="0.5pt solid blue">
		<fo:block text-align="center" font-size="9pt" color="green"
font-weight="bold">
			<xsl:value-of select="@column3"/>
		</fo:block>
	</fo:table-cell>
	<fo:table-cell border="0.5pt solid blue">
		<fo:block text-align="center" font-size="9pt" color="green"
font-weight="bold">
			<xsl:value-of select="@column4"/>
		</fo:block>
	</fo:table-cell>
	<fo:table-cell border="0.5pt solid blue">
		<fo:block text-align="center" font-size="9pt" color="green"
font-weight="bold">
			<xsl:value-of select="@column5"/>
		</fo:block>
	</fo:table-cell>
	<fo:table-cell border="0.5pt solid blue">
		<fo:block text-align="center" font-size="9pt" color="green"
font-weight="bold">
			<xsl:value-of select="@column6"/>
		</fo:block>
	</fo:table-cell>
	<fo:table-cell border="0.5pt solid blue">
		<fo:block text-align="center" font-size="9pt" color="green"
font-weight="bold">
			<xsl:value-of select="@column7"/>
		</fo:block>
	</fo:table-cell>
	<fo:table-cell border="0.5pt solid blue">
		<fo:block text-align="center" font-size="9pt" color="green"
font-weight="bold">
			<xsl:value-of select="@column8"/>
		</fo:block>
	</fo:table-cell>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
-------------------------------------
The problem is:
When I an trying to convert this xml file to pdf format, I am getting ERROR
message:
[ERROR] java.lang.ArrayIndexOutOfBoundsException: -2
What could be the reason?
When I remove the "Column 6" part, I am able to generate pdf.
Please help me out.

Girish Kanmas
TI Extn: 1387
Mobile: 091-80-56728348
Received on Wednesday, 22 October 2003 06:05:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:11 GMT