5

I'm working with Tridion 2011: when a table is created in a rich text formated field of a Tridion component it works correctly, but when I save the component and I open it again for editting, if I change the content of the table some fields disappear. I guess the problem is that the namespace I set for my table (xmlns="http://www.w3.org/1999/xhtml") "disappears" when I save for the first time.

The xslt set in the schema used is (notice I set he xmlns in the tag "table"):

<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
...
<template match="table | TABLE">
    <!-- Se comprueba que no existe ya el div class="C29" y se escribe el inicio de la etiqueta -->
    <choose>
        <when test="../../div[@class=&apos;C29&apos;]">
            <!-- No hacer nada -->
        </when>
        <otherwise>
            <text disable-output-escaping="yes">&lt;div class="C29"&gt;</text>
        </otherwise>
    </choose>
    <table xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <copy-of xmlns="http://www.w3.org/1999/XSL/Transform" select="@cellspacing | @cellSpacing | @cellpadding | @cellPadding | @summary"></copy-of>
        <!-- Escribe el colgroup -->
        <choose xmlns="http://www.w3.org/1999/XSL/Transform">
            <!-- Si tiene ya colgroup se pinta tal y como está -->
            <when test="colgroup">
                <apply-templates select="colgroup"></apply-templates>
            </when>
            <!-- sino, se escribe -->
            <otherwise>
                <colgroup xmlns="http://www.w3.org/1999/xhtml">
                    <choose xmlns="http://www.w3.org/1999/XSL/Transform">
                        <!-- Si tiene la etiqueta tBody -->
                        <when test="tbody">
                            <for-each select="tbody/tr">
                                <call-template name="escribir-colgroup"></call-template>
                            </for-each>
                        </when>
                        <!-- Si NO tiene la etiqueta tBody -->
                        <otherwise>
                            <for-each select="tr">
                                <call-template name="escribir-colgroup"></call-template>
                            </for-each>
                        </otherwise>
                    </choose>
                </colgroup>
            </otherwise>
        </choose>
        <!-- Escribe el thead -->
        <choose xmlns="http://www.w3.org/1999/XSL/Transform">
            <when test="thead">
                <apply-templates select="thead"></apply-templates>
            </when>
            <otherwise>
                <for-each select="//tr">
                    <choose>
                        <when test="position()=1">
                            <thead xmlns="http://www.w3.org/1999/xhtml">
                                <tr>
                                    <for-each xmlns="http://www.w3.org/1999/XSL/Transform" select="td">
                                        <element name="th">
                                            <attribute name="scope">col</attribute>
                                            <choose>
                                                <when test="@align=&apos;left&apos;">
                                                    <attribute name="class">alignLeft</attribute>
                                                </when>
                                                <when test="@align=&apos;right&apos;">
                                                    <attribute name="class">alignRight</attribute>
                                                </when>
                                                <when test="@align=&apos;middle&apos;">
                                                    <attribute name="class">alignCenter</attribute>
                                                </when>
                                                <otherwise>
                                                    <if test="@class">
                                                        <attribute name="class">
                                                            <value-of select="@class"></value-of>
                                                        </attribute>
                                                    </if>
                                                </otherwise>
                                            </choose>
                                            <copy-of select="* | node()"></copy-of>
                                        </element>
                                    </for-each>
                                </tr>
                            </thead>
                        </when>
                    </choose>
                </for-each>
            </otherwise>
        </choose>
        <!-- Escribe el tfoot -->
        <choose xmlns="http://www.w3.org/1999/XSL/Transform">
            <when test="tfoot">
                <apply-templates select="tfoot"></apply-templates>
            </when>
            <otherwise>
                <tfoot xmlns="http://www.w3.org/1999/xhtml"></tfoot>
            </otherwise>
        </choose>
        <!-- Escribe el tbody -->
        <tbody>
            <choose xmlns="http://www.w3.org/1999/XSL/Transform">
                <!-- Si tiene la etiqueta tBody -->
                <when test="tbody">
                    <for-each select="//tr">
                        <choose>
                            <when test="position()!=1">
                                <call-template name="escribir-tbody"></call-template>
                            </when>
                        </choose>
                    </for-each>
                </when>
                <otherwise>
                    <for-each select="tr">
                        <call-template name="escribir-tbody"></call-template>
                    </for-each>
                </otherwise>
            </choose>
        </tbody>
    </table>
    <!-- Se comprueba que no existe ya el div class="C29" y se escribe el cierre de la etiqueta -->
    <choose>
        <when test="../../div[@class=&apos;C29&apos;]">
            <!-- No hacer nada -->
        </when>
        <otherwise>
            <text disable-output-escaping="yes">&lt;/div&gt;</text>
        </otherwise>
    </choose>
</template>

This is the xml set when I build the table for the first time:

<div class="C29">
<table xmlns="http://www.w3.org/1999/xhtml" cellpadding="1" cellspacing="1">
    <colgroup>
        <col xmlns="http://www.w3.org/1999/XSL/Transform"/>
        <col xmlns="http://www.w3.org/1999/XSL/Transform"/>
    </colgroup>
    <thead>
        <tr>
            <th xmlns="http://www.w3.org/1999/XSL/Transform" scope="col">Field 1</th>
            <th xmlns="http://www.w3.org/1999/XSL/Transform" scope="col">Field 2</th>
        </tr>
    </thead>
    <tbody>
        <tr class="impar">
            <td xmlns="http://www.w3.org/1999/XSL/Transform">Result 1</td>
            <td xmlns="http://www.w3.org/1999/XSL/Transform">Result 2</td>
        </tr>
    </tbody>
</table>

This is the xml when I save the component and I open it again (the namespace is missing):

<div class="C29">
<table cellpadding="1" cellspacing="1">
    <colgroup>
        <col xmlns="http://www.w3.org/1999/XSL/Transform"/>
        <col xmlns="http://www.w3.org/1999/XSL/Transform"/>
    </colgroup>
    <thead>
        <tr>
            <th xmlns="http://www.w3.org/1999/XSL/Transform" scope="col">Field 1</th>
            <th xmlns="http://www.w3.org/1999/XSL/Transform" scope="col">Field 2</th>
        </tr>
    </thead>
    <tbody>
        <tr class="impar">
            <td xmlns="http://www.w3.org/1999/XSL/Transform">Result 1</td>
            <td xmlns="http://www.w3.org/1999/XSL/Transform">Result 2</td>
        </tr>
    </tbody>
</table>

This is the xml when I edit any field of the table (the xmlns "appears" again, but the boby of the table is missing):

<div class="C29">
<table xmlns="http://www.w3.org/1999/xhtml" cellpadding="1" cellspacing="1">
    <colgroup xmlns="">
        <col xmlns="http://www.w3.org/1999/XSL/Transform"/>
        <col xmlns="http://www.w3.org/1999/XSL/Transform"/>
    </colgroup>
    <thead xmlns="">
        <tr>
            <th xmlns="http://www.w3.org/1999/XSL/Transform" scope="col">Field 1</th>
            <th xmlns="http://www.w3.org/1999/XSL/Transform" scope="col">Fieldd 2</th>
        </tr>
    </thead>
    <tfoot></tfoot>
    <tbody>
        <tr class="impar"></tr>
    </tbody>
</table>

The key is the missing xmlns in the second step: if I add it manually each time I try to edit the component the problem is solved, but I must try to find out how to solve it definitelly.

1
  • 1
    You should probably contact Customer Support about this issue. I vaguely remember some hotfixes related to this, but I could be wrong about that. Commented Dec 19, 2013 at 15:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.