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

Transforming Tables

Subject: Transforming Tables
From: Jeff Sese <jsese@xxxxxxxxxxxx>
Date: Thu, 04 May 2006 13:19:15 +0800
indesign xml table
Good day!

I'm transforming a table xml into a InDesign tagged text table and i'm
having a problem when it comes to spanning. In InDesign tagged text a
cell is constructed this way: <clStart:x,y>data<clEnd:>, x is the number
of rows and y the number columns occupied by the cell. However, if the
table has 5 columns then each row must have 5 cell entries as well
regardless if there exist a cell the spans the rest of the column or a
previous cell that spans the row position.

So if you have a table xml like this:
<table row="4" col="5">
<row>
<cell col="1">Data</cell>
<cell col="2" colspan="3">Data</cell>
<cell col="5">Data</cell>
</row>
<row>
<cell col="1" rowspan="3">Data</cell>
<cell col="2">Data</cell>
<cell col="3">Data</cell>
<cell col="4">Data</cell>
<cell col="5">Data</cell>
</row>
<row>
<cell col="2" rowspan="2">Data</cell>
<cell col="3">Data</cell>
<cell col="4">Data</cell>
<cell col="5">Data</cell>
</row>
<row>
<cell col="3">Data</cell>
<cell col="4">Data</cell>
<cell col="5">Data</cell>
</row>
</table>

You should have a InDesign tagged text like this:
<tStart:4,12>
<rStart:>
<cStart:1,1>Data<cEnd:>
<cStart:1,3>Data<cEnd:>
<cStart:1,1><cEnd:>
<cStart:1,1><cEnd:>
<cStart:1,1>Data<cEnd:>
<rEnd:>
<rStart:>
<cStart:3,1>Data<cEnd:>
<cStart:1,1>Data<cEnd:>
<cStart:1,1>Data<cEnd:>
<cStart:1,1>Data<cEnd:>
<cStart:1,1>Data<cEnd:>
<rEnd:>
<rStart:>
<cStart:1,1><cEnd:>
<cStart:2,1>Data<cEnd:>
<cStart:1,1>Data<cEnd:>
<cStart:1,1>Data<cEnd:>
<cStart:1,1>Data<cEnd:>
</row>
<rEnd:>
<cStart:1,1><cEnd:>
<cStart:1,1><cEnd:>
<cStart:1,1>Data<cEnd:>
<cStart:1,1>Data<cEnd:>
<cStart:1,1>Data<cEnd:>
<rEnd:>
<tEnd:>

I can get my xslt to handle column spanning, but i'm having trouble with
rowspanning. Here is my template for the cell element:
<xsl:template match="cell">
<xsl:variable name="col" select="if (exists(@colspan) then @colspan else
1)"/>
<xsl:variable name="row" select="if (exists(@rowspan) then @rowspan else
1)"/>
<xsl:value-of select="concat('<cStart:',$row,',',$col,'>')"/>
<xsl:apply-templates/>
<xsl:value-of select="'<cEnd:'"/>
<xsl:if test="exists(@colspan)">
<xsl:value-of select="for $x in (1 to @colspan-1) return
'<cStart:1,1><cEnd:>'"/>
</xsl:if>
</xsl:template>

Can someone help me with generating the empty cells for row spanning?

Thanks,
Jeff

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.