6

In a Rich Text Field of a Component I add in some text for e.g. "This is my first line. This will be my second line.". I then hit Enter after "line.".

At this point when I view the source, I see the following:

<p>This is my first line.&#160;</p>
<p>This will be my second line.</p>

As expected.

However, now I go back into the design tab and click backspace to essentially have all the text in one line and this is how my source becomes:

<p>This is my first line.&#160;<span style="font-size: 12px; font-family: Verdana;">This will be my second line.</span></p>

Where are these span tags coming from? How can I remove them to just keep the p tags? We are using Tridion 2011 SP1. Also, if it helps at all, I have tried replicating the same issue on another Tridion environment and this doesn't happen. So I believe this is a configuration thing, but don't really know where to start.

UPDATE 1

The XSLT for one of the Schema fields is shown below.

<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
<output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></output>
<template match="/ | node() | @*">
    <copy>
        <apply-templates select="node() | @*"></apply-templates>
    </copy>
</template>
<template match="*[      (self::br or self::p or self::div)     and      normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;     and      not(@*)     and      not(processing-instruction())     and      not(comment())     and      not(*[not(self::br) or @* or * or node()])     and      not(following::node()[not(         (self::text() or self::br or self::p or self::div)        and         normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;        and         not(@*)        and         not(processing-instruction())        and         not(comment())        and         not(*[not(self::br) or @* or * or node()])       )])     ]">
    <!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks -->
</template>
<template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]">
    <!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space -->
    <text> </text>
</template>

There are other RTFs that have the same issue too.

UPDATE 2

I have also looked at the XSLTs in the following location \TRIDION_HOME\Program Files (x86)\Tridion\web\WebUI\Core\Controls\FormatArea\XSLTs. I've compared these to working versions and both sets are identical.

UPDATE 3

Further to Robs comment, I have tested this across different browsers and can confirm this only happens in Chrome - all other browsers are fine.

9
  • Could you post your XSLT for the schema field? Maybe something weird going on in that? Oct 31, 2013 at 12:59
  • Thanks Rob, done. If it helps, I have compared this XSLT to a schema field of another Tridion environment where this problem doesn't exist and it's the same. So I don't think it's an XSLT issue. One thing I have noticed is, after doing a comparison of the two, the Allowed Styles tab contains different items. Not sure if this would cause span tags to appear? Oct 31, 2013 at 13:31
  • Is there anything different in the schema field? Specifically, have you disabled any of the formatting features? Oct 31, 2013 at 15:17
  • Hi JDubz, I disabled every option in Allowed Styles and Allowed Actions (may have went over the top doing this), but the problem still exists. Only difference between the schema fields is, the one that works (bear in mind this is a totally different environment to that which doesn't work) has a different "height rows" option. But I don't see how changing the height would be the cause of this. Oct 31, 2013 at 15:44
  • Could this be a browser issue? Are you checking in the same browser? Have the same hotfixes been applied to both environments? Oct 31, 2013 at 19:18

1 Answer 1

1

You need to apply a template match for removing set of html tags which needs to be separated by Pipe symbol (|) such as span|em|p|br|i

Example:

<!-- Remove disallowed elements but keep its children -->
<template match="span|em">
    <apply-templates/>
</template>

Your Filter XSLT will look like this

<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"/>
    <template match="/ | node() | @*">
        <copy>
            <apply-templates select="node() | @*"/>
        </copy>
    </template>
    <template match="*[      (self::br or self::p or self::div)     and      normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;     and      not(@*)     and      not(processing-instruction())     and      not(comment())     and      not(*[not(self::br) or @* or * or node()])     and      not(following::node()[not(         (self::text() or self::br or self::p or self::div)        and         normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;        and         not(@*)        and         not(processing-instruction())        and         not(comment())        and         not(*[not(self::br) or @* or * or node()])       )])     ]">
        <!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks -->
    </template>
    <template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]">
        <!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space -->
        <text> </text>
    </template>
    <!-- Remove disallowed elements but keep its children -->
    <template match="span|em">
        <apply-templates/>
    </template>
</stylesheet>
5
  • Thanks Siva. Only thing is that doesn't explain why the other Tridion environments I have tested against work fine and don't have this problem? The Filtering XSLT on other environments are the same to the one I am having issues with. Oct 31, 2013 at 14:21
  • @IbrarHussain: That's weird. Let me think, in the mean while try my suggestion. Oct 31, 2013 at 14:32
  • I did try your suggestion, restarted the COM+. Didn't work. Oct 31, 2013 at 14:45
  • @IbrarHussain: I have tested your Filter XSLT which is working fine as expected. I suspect that you are looking on different schema/field and testing on another schema/field. Just check it out. Oct 31, 2013 at 14:50
  • Hi Siva, I'm definitely looking at the right field and testing the correct one too. I did suspect this but have tried again just now, same problem. Oct 31, 2013 at 15:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.