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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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/

   
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.