1

We did upgrade from Tridion 5.3 to Tridion 2011 SP1.

In Tridion 5.3 we were using VBScript Templates, as a part of this upgrade we are converting existing VBScript Templates to Compound Component Templates. We are facing below mentioned two issues with the content of RTF field.

Issue 1 : In our existing content of RTF field we have empty tags/HTML Tags at number of locations. eg.<a name="Contact" id="Contact"></a> When we publish the content with Compound Component Templates (Tridion 2011 SP1 environment) above mentioned anchor tag is getting converted to <a name="Contact" id="Contact" />. This is breaking existing javascript functionality. To overcome the issue we have written C# functions which finds empty tags and replace the inner text with &nbsp; like <a name="Contact" id="Contact">&nbsp;</a> then things are working fine. But to call this function at CT level for each RTF field is big activity as we have number Component Tempate. Is there any better way to do it.

Issue 2 : In the same RTF field we have content like &#160; (may be editors have copy pasted it from web or somewhere), so when we try to publish page or component it is getting failed with error. JScriptException:Expression valueUnterminated String Constant.

Is there any default TBB which will help to fix the issues?

user1453602
  • 1,165
  • 5
  • 14

2 Answers2

2

Issue 1:

You can also use a Filtering XSLT to modify your RTF content on component save.

This way you can replace any empty tag <tag></tag> with <tag>&nbsp;</tag> on component save and don't need any further change on templating.

Issue 2:

&#160; seems like an encoded &nbsp;, see character codes: http://www.escapecodes.info/

Maybe you can replace this character codes with the proper html encoding, using a filtering xslt or a C# TBB

Puntero
  • 2,310
  • 15
  • 18
  • It is a bit strange that you should get an error with   because it is a valid numeric entity. Anyway, you can try to replace it with the same XSLT like this: – Quirijn Nov 02 '12 at 11:12
0

As you already have a function for converting inline closed anchor tags to anchor tags with a non-breaking space in them you could consider using this function from your page template(s) instead of using it in every component template; this would require a much smaller number of templates to change...

You also might want to consider replacing inline closed anchor tags with properly closed anchor tags without actually inserting extra spaces.

Below is a C# fragment you can use in a TBB to replace inline closed anchor tags:

Item outputItem = package.GetByName(pcakge.OutputName);
package.Remove(outputItem);
string outputString = Regex.Replace(outputItem.GetAsString(), "(<a[^>]*?)/>", "$1></a>", RegexOptions.Singleline);
outputItem.SetAsString(outputString);
package.PushItem(Package.OutputName, outputItem);

You could extend it to also replace &#160; with &nbsp; but this should not cause any issues as &#160; is a valid escape sequence in HTML (Tridion RTF fields are essentially XML which could be the cause for &#160; appearing instead of &nbsp;...).

Bjørn van Dommelen
  • 1,057
  • 7
  • 13