xsl-list
[Top] [All Lists]

Re: Convert CALS Table

2005-02-21 08:26:19
hallo,

i've found a solution via manipulating xml in java. if someone is interested in the source - write me a mail.

but i'm still interested in the question if this problem is solvable in xslt. i'm more interested in an idea, than in a complete working stylesheet.

thanks
gregor


Am Fri, 18 Feb 2005 20:10:13 +0100 schrieb gregor FELLENZ <gf_public(_at_)gmx(_dot_)net>:

hello xsl-list,

i have to normalize CALS tables, to another table model which has no
colspan resp. rowspan abilities.

I have to fill for each omitted entry an empty cell in my new
document, to generate valid tables.

Realizing this for colspan is no problem (as you can see in my
xslt) but i have no idea how to cover the rowspan.
The problem is, that i have to insert in every spanned row an empty
cell, but how can i gather this information?

Any ideas or hints how i can realize this?

Thanks

gregor

*** MY XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output indent="yes" method="xml"/>
<xsl:template match="table">
        <tablex>
                <xsl:apply-templates/>
        </tablex>
</xsl:template>

<xsl:template match="row">
        <row>
                <xsl:for-each select="entry">
                        <xsl:choose>
                                <xsl:when test="@namest != '' ">
<xsl:variable name="temp" select="@nameend"/> <xsl:variable name="ende" select="ancestor::*/colspec[(_at_)colname = $temp]/@colnum"/>
                                        <cell>
                                                <xsl:apply-templates/>
                                        </cell>
<xsl:call-template name="zellenschreiben"> <xsl:with-param name="anzahl" select="1"/> <xsl:with-param name="ende" select="$ende -position()"/>
                                        </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                        <cell>
                                                <xsl:apply-templates/>
                                        </cell>
                                </xsl:otherwise>
                        </xsl:choose>
                </xsl:for-each>
        </row>
</xsl:template>

<xsl:template name="zellenschreiben">
        <xsl:param name="anzahl"/>
        <xsl:param name="ende"/>
        <xsl:if test="$anzahl &lt;= $ende">
                <cell/>
                <xsl:call-template name="zellenschreiben">
<xsl:with-param name="anzahl" select="$anzahl + 1"/>
                        <xsl:with-param name="ende" select="$ende"/>
                </xsl:call-template>
        </xsl:if>
</xsl:template>
</xsl:stylesheet>


*** Source Example, its CALS
<table>
        <tgroup cols="4">
<colspec colnum="1" colname="spycolgen1" colwidth="1.0*"/> <colspec colnum="2" colname="spycolgen2" colwidth="1.0*"/> <colspec colnum="3" colname="spycolgen3" colwidth="1.0*"/> <colspec colnum="4" colname="spycolgen4" colwidth="1.0*"/>
                <tbody>
                        <row>
<entry namest="spycolgen1" nameend="spycolgen3">colspan</entry>
                                <entry>2</entry>
                        </row>
                        <row>
                                <entry morerows="1">rowspan</entry>
                                <entry>4</entry>
                                <entry>5</entry>
                                <entry>6</entry>
                        </row>
                        <row>
                                <entry>7</entry>
                                <entry>8</entry>
                                <entry>9</entry>
                        </row>
                </tbody>
        </tgroup>
</table>

*** Result ...
<tablex>
        <row>
                <cell>colspan</cell>
<cell/><!-- This empty cell comes from the colspan ... -->
                <cell/>
                <cell>2</cell>
        </row>
        <row>
                <cell>rowspan</cell>
                <cell>4</cell>
                <cell>5</cell>
                <cell>6</cell>
        </row>
        <row>
                <!-- Here I need another <cell/> to get valid code -->
                <cell>7</cell>
                <cell>8</cell>
                <cell>9</cell>
        </row>
</tablex>




--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/m2/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--