Subject: Re: [xsl] Transforming Tables - repost From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 16 May 2006 11:53:41 +0100 |
something like this perhaps <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="table"> <xsl:text> <tStart:</xsl:text> <xsl:value-of select="@row"/> <xsl:text>:</xsl:text> <xsl:value-of select="@col"/> <xsl:text>></xsl:text> <xsl:apply-templates select="row"/> <xsl:text> <tEnd:> </xsl:text> </xsl:template> <xsl:template match="row"> <xsl:text> <rStart:></xsl:text> <xsl:variable name="here" select="."/> <xsl:for-each select="1 to ../@col"> <xsl:variable name="cell" select="$here/cell[@col=current()]"/> <xsl:text> <cStart:</xsl:text> <xsl:value-of select="max(($cell/@rowspan,1))"/> <xsl:text>,</xsl:text> <xsl:value-of select="max(($cell/@colspan,1))"/> <xsl:text>></xsl:text> <xsl:apply-templates select="$cell/node()"/> <xsl:text><cEnd:></xsl:text> </xsl:for-each> <xsl:text> <rEnd:></xsl:text> </xsl:template> </xsl:stylesheet> which on <tables> <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> <table row="3" col="5"> <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> </tables> produces <tStart:4:5> <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:> <rEnd:> <rStart:> <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:> <tStart:3:5> <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:> <rEnd:> <rStart:> <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:> which is more or less what you asked for except in the first table you said you needed <tStart:4,12> but I'm not sure where the 12 came from. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Transforming Tables - rep, David Carlisle | Thread | Re: [xsl] Transforming Tables - rep, Jeff Sese |
Re: [xsl] Transforming Tables - rep, David Carlisle | Date | RE: [xsl] Wrapping a Condition arou, Kevin Bird \(Matrix\ |
Month |