smart paste, table tgroup error
I have started a custom smart paste script for copying from word to framemaker 12 and most of my code works except for the table template. That is, it works perfectly fine the first time I use smart paste to get a table, but the second time (and all times after that) it fails. I get the tgroup element within the entry element istead of outside the tbdy element, and I have no idea why this is. Can anyone help me?
My code:
<xsl:template match="table">
<xsl:variable name="cols-in-first-row">
<xsl:choose>
<xsl:when test="tbody[1]/tr">
<xsl:value-of select="count(tboy[1]/tr[1]/td|th)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(tr[1]/td|th)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<TableObject>
<Table>
<Tgroup cols="{$cols-in-first-row}">
<xsl:call-template name="create-colspec">
<xsl:with-param name="total-cols">
<xsl:value-of select="$cols-in-first-row"/>
</xsl:with-param>
</xsl:call-template>
<Tbody>
<xsl:apply-templates/>
</Tbody>
</Tgroup>
</Table>
</TableObject>
</xsl:template>
<xsl:template name="create-colspec">
<xsl:param name="total-cols">0</xsl:param>
<xsl:param name="on-column">1</xsl:param>
<xsl:if test="$on-column <= $total-cols">
<Colspec Colname="{$on-column}">
<xsl:if test="@align">
<xsl:attribute name="align">
<xsl:value-of select="@align"/>
</xsl:attribute>
</xsl:if>
</Colspec>
<xsl:call-template name="create-colspec">
<xsl:with-param name="total-cols">
<xsl:value-of select="$total-cols"/>
</xsl:with-param>
<xsl:with-param name="on-column">
<xsl:value-of select="$on-column + 1"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="table/caption">
<Title>
<xsl:apply-templates/>
</Title>
</xsl:template>
<xsl:template match="tr">
<Row>
<xsl:apply-templates/>
</Row>
</xsl:template>
<xsl:template match="td|th">
<Entry>
<xsl:apply-templates/>
</Entry>
</xsl:template>
[Message moved to Structured Forum by moderator]
