Skip to main content
agarnaas
Participant
April 21, 2015
Answered

smart paste, table tgroup error

  • April 21, 2015
  • 2 replies
  • 353 views

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 &lt;= $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]

This topic has been closed for replies.
Correct answer agarnaas

It doesn't seem like anyone else has this problem, but I will still post my "solution" here.

I figured out that you have to save the file before smart pasting another table into the document. I don't know if this is a bug or if the Framemaker developers did this on purpose, but if I don't save the file after smart pasting one table the next table will look like this:

<table>

     <tbody>

          <row>

               <entry>

                    <tgroup/>

               </entry>

          </row>

     </tbody>

</table>

which, of course, creates an error in the structure and nothing of the content in the table gets pasted in.

So, in short! Nothing wrong with the code, but you need to save the framemaker file after pasting in a table/before pasting in a new table.

2 replies

agarnaas
agarnaasAuthorCorrect answer
Participant
April 27, 2015

It doesn't seem like anyone else has this problem, but I will still post my "solution" here.

I figured out that you have to save the file before smart pasting another table into the document. I don't know if this is a bug or if the Framemaker developers did this on purpose, but if I don't save the file after smart pasting one table the next table will look like this:

<table>

     <tbody>

          <row>

               <entry>

                    <tgroup/>

               </entry>

          </row>

     </tbody>

</table>

which, of course, creates an error in the structure and nothing of the content in the table gets pasted in.

So, in short! Nothing wrong with the code, but you need to save the framemaker file after pasting in a table/before pasting in a new table.

Participating Frequently
April 21, 2015

I've not looked through your code in any detail, but noticed a typo on line 5:

<xsl:value-of select="count(tboy[1]/tr[1]/td|th)"/>

It looks like "tboy" should be "tbody".

agarnaas
agarnaasAuthor
Participant
April 22, 2015

Thank you for responding. I have already seen and corrected this error, but the same problem still stands