XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Anu NairSubject: Column Span Problem
Author: Anu Nair
Date: 22 Mar 2006 03:03 AM
Hi,
I am having a problem in XML transformation to XSL-FO.
The problem is with transforming a table cell which has to span 2 or more columns.

Below is the XML for the same.
<table>
<colspec column-name="x" column-width="25%"/>
<colspec column-name="y" column-width="50%"/>
<colspec column-name="z" column-width="25%"/>
<tbody>
<row>
<cell>data1</cell>
<cell colstart="y" colend="z">data2</cell>
</row>
</tbody>
</table>

The problem is I have to get the column numbers (start and end) and subtract to arrive at the number-columns-spanned for the table cell.
I tried doing this:
1. Loop through the colspec tags to check whether the column name matches with the end column name.
2. If column names match, set the fo:table-cell attribute "number-columns-spanned" to the end column number (using position()).
3. Loop through the colspec tags again to match the start column.
4. If columns match, get the current value of attribute number-column-spanned and subtract the start column number from it.
This would be the columns spanned value.

<xsl:template match="cell">
<fo:table-cell>
<fo:block>

<xsl:variable name="endcolumn" select="@colend"/>

<xsl:attribute name="number-columns-spanned">
<xsl:for-each select="../tbody/colspec">
<xsl:if test="$endcolumn=@colname">
<xsl:value-of select="position()"/>
</xsl:if>
</xsl:for-each>
</xsl:attribute>

<!--i am getting the current value of the no.-cols-spanned attribute here-->
<xsl:variable name="nocolspan" select="number-columns-spanned"/>

<!--getting the start col number and subtracting from current value of attribute to get the new no.-cols-spanned value-->
<xsl:variable name="startcolumn" select="@colstart"/>

<xsl:attribute name="number-columns-spanned">
<xsl:for-each select="../tbody/colspec">
<xsl:if test="$startcolumn=@colname">
<xsl:value-of select="$nocolspan - position() + 1"/>
</xsl:if>
</xsl:for-each>
</xsl:attribute>

</fo:block>
</fo:table-cell>
</xsl:template>

However, this approach doesn't seem to work. Could someone help me proceed with this?
Thanks in advance,
Anu

Posttop
Minollo I.Subject: Column Span Problem
Author: Minollo I.
Date: 22 Mar 2006 08:55 AM
You may want to consider asking generic XSLT questions on the xsl-list mailing list, which specializes in general-purpose XSLT issues.

See http://www.mulberrytech.com/xsl/xsl-list/

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.