I'm using Tridion 2011 SP1 HR1 and have created a new schema with one RTF field and have applied the following filtering XSLT:

<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() | @*">      
      <apply-templates select="node() | @*"/>
  <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 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>
  <!-- remove disallowed elements but keep its children -->
  <template match="li/p">
  <template match="h1">
    <element name="p">
  <template match="head | title | meta | base | style | scriptlink | font | ilayer | layer | small | u | span">
  <!-- remove dissallowed attributes -->
  <template match="@style" />
  <template match="@bordercolor" />
  <template match="@class[.=&apos;MsoNormal&apos; or .=&apos;MsoNormalCxSpMiddle&apos; or .=&apos;MsoNormalCxSpLast&apos; or .=&apos;MsoTableGrid&apos; or .=&apos;MsoListParagraphCxSpFirst&apos; or .=&apos;MsoListParagraphCxSpMiddle&apos; or .=&apos;MsoListParagraphCxSpLast&apos;]" />
  <!--<template match="@align | @valign | @border | @cellpadding | @cellspacing"/>-->  
  <!-- remove all style attributes except those for a table cel to allow center alignment -->
  <!--<template match="*[not(local-name() = &apos;td&apos;)]/@style"/>
  <template match="td/@style">
    <if test="contains(.,&apos;text-align&apos;)">
      <attribute name="style">
  <!-- remove rowspan and collspan when set to 1 -->
  <template match="@colspan[.=&apos;1&apos;] | @rowspan[.=&apos;1&apos;]"/>

This works fine except for this match:

<template match="h1">
    <element name="p">

Whenever the input is:


I expect the following output:


but instead, I'm getting a copy of the full xmlns as an attribute:

<p xmlns="http://www.w3.org/1999/XSL/Transform">Test</p>

From the research I've done so far, it has to do with the <copy> element from the XSLT transformation. How should I modify my filtering XSLT to fix this?


In order to remove the namespace from the <p> element, all you have to do is apply a blank namespace attribute. The final (correct) filtering XSLT is the same as the original except for this line:

<element name="p" namespace="">

Once I applied this change, I was able to get the correct output:

  • Hacky... but I don't know of another solution right now. – Mihai Cădariu Nov 15 '13 at 17:39

You may try to put 'exclude-result-prefixes' in stylesheet header. There are so many links with explanation how to do this. I just picked up one as example. https://stackoverflow.com/questions/827600/how-can-i-prevent-these-redundant-namespaces-from-an-xslt-stylesheet

  • It didn't work. I tried the following: <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="#default"> and <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="#all"> – Haniel Pulido Jr Nov 15 '13 at 14:58
  • I never used #all in this attribute - could you try explicitly adding the prefixes instead (separated by spaces)? – Nuno Linhares Nov 15 '13 at 18:47

With the disclaimer of not having tried it, this is what I suggest:

Declare an xhtml namespace in your stylesheet:


Declare to exclude namespace prefix xhtml from result:


Finally, create your p element belonging to the xhtml namespace:

<element name="p" namespace="xhtml">
  • When applying this fix, the output is now <p xmlns="xhtml">Test</p>. Although not quite right, this has now led me to the solution. All you have to do is apply a blank namespace to the element: <element name="p" namespace="">. Thank you. – Haniel Pulido Jr Nov 15 '13 at 16:27
  • I noticed that Tridion strips the namespace prefix declaration from the 'stylesheet' element when saving the Schema. This is why you end up with the xmlns attribute in your 'p' tag. – Mihai Cădariu Nov 15 '13 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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