Documentation Center

Tidying up RTF content

An XSLT filter is applied to Rich Text Fields (format areas) to tidy content pasted into it, for example from Microsoft Word. You can adjust the XSLT filter to act more or less aggressively on pasted content, or you can replace it for the default or your own custom version.

About this task

The XSLT filter used in the List Element and Paragraph Embeddable Schemas removes the following (disallowed) elements from the HTML in the format area:
  • all font tags from the HTML but keep its children
  • all style attributes except those for a table and its cells and allow underline to span tags
  • rowspan and collspan attributes when set to 1
  • well known Microsoft Word classes (starting with Mso or mso)
  • conditional comments that Microsoft Word uses, for example:
    <!––[if gte mso 9]>
     
    <![endif]––>

Procedure

  1. Access the Content Manager Explorer Web site.
  2. Navigate to the \100 Master\Building Blocks\Modules\Core\Editor\Schemas\Embedded.
  3. Open the Item List Element Schema or Paragraph Schema.
  4. Click the Edit Formatting Features button for the format area field.
  5. In the Filtering XSLT tab, customize the XSLT. For example, use the standard XSLT filter applied to a format area field in SDL Tridion:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    	<xsl:output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></xsl:output>
    	<xsl:template match="/ | node() | @*">
    		<xsl:copy>
    			<xsl:apply-templates select="node() | @*"></xsl:apply-templates>
    		</xsl:copy>
    	</xsl:template>
    	<xsl: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 -->
    	</xsl:template>
    	<xsl: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 -->
    		<xsl:text> </xsl:text>
    	</xsl:template>
    </xsl:stylesheet>
  6. Click Save and Close.