9

What are some ways to allow an RTF field to preserve empty tags?

One way I can think of is using XSLT formatting (Filtering XSLT tab in Formatting Features) on the specific field. Does anyone have other suggestions?

Thanks!

4 Answers 4

7

in this issue, Tridion converts <p></p> to <p/>, however HTML is not XML, so after my migration project, this is cause HTML error or JavaScript error for many cases, i added &#160; (in HTML is &nbsp;) <p>&#160;</p>, this will create a visible space to the HTML rendering. so continue to solve by adding <span style="display:none"> tag to hide the space...

i realize HTML is not equal to XML.

5

I bumped into this problem during a migration from R5 to 2011, and the way I solved it was by inserting a non breaking space inside the empty tags (turning <p/> and <p></p> to <p>&#160;</p>, for instance), and changing every instance of &nbsp; to &#160;.

However I was using a 3rd party tool that could do it "on the fly" during the migration, so I don't know how applicable it is in your case.

5

There is absolutely no need of such over-engineering (XSLT framework) or solutions which involves inclusion of unexpected characters (like non breaking space or p tags) as it may spoil the final HTML layouts depending on your HTML/CSS.

In SDL Tridion 2011, it is very simple to achieve indeed; follow below step:

1) On your CMS server, navigate to the following path: ..\TridionWeb\WebUI\Core\Controls\FormatArea\TcmXhtml

2) Open the configuration file named - TcmXHTML

3) In this configuration file locate the tag - new-empty-tags:

4) You may see few tags like command, source track etc. already there separated by a space.

5) Add all your tags which you want keep as empty tags separated by a space: For Example: If your tag entry looks like -

new-empty-tags: command source track

and apart from these you want preserve the following tags as empty - emptytag1, emptytag2 then update the tag entry as -

new-empty-tags: command source track emptytag1 emptytag2

6) Restart the SDL Tridion Content Manager DCOM+ Application and reload the CME

You will now be able to add and preserve tags like and

In addition, you can explore further and this configuration file can be used further to change the behaviour of your RTF fields

3
  • Wow, nice! Thanks for that, it will be useful in the future!
    – m4573r
    Commented Apr 3, 2013 at 9:59
  • Note that the additions/updates to the TcmXhtml file should be tracked because updates to this file are not supported by SDL Tridion Support and could be overwritten in future Hotfixes/udpates. Commented May 2, 2013 at 1:14
  • Yup absolutely correct, and the best option is to raise a ticket to the support in parallel and take their buy-in for changes to tcmXhtml file. Commented May 2, 2013 at 3:18
3

I am not sure you'll find a way to do this, since in XML a <tag/> is equivalent to <tag></tag> and the Tridion RTF is a XML field.

Many (most? all?) xml libraries will automatically convert "empty" tags to the closed form, and I believe Tridion will do this on save. The only solution I've seen so far seems to be to insert a non-breaking space.

An alternative solution would be to insert a character that you can potentially remove at publish time, but I didn't play around with this enough to tell you if it will work.

2
  • 1
    I think you can say all XML libraries will do this. The point is that before it is processed by the XSLT, your RTF content is loaded into a DOM document object (of whatever implementation). This means that it becomes a tree of nodes of various types. The serialization format of XML allows two ways of expressing a "tag" node that has no children. In the "Infoset" representation, it's just a node with no children. Artificially introducing a child is the only way I know of to ensure you get a closing tag when you serialize again. Commented Apr 11, 2013 at 5:56
  • An alternative to removing a character at publish time might be to transform empty tags to their verbose format. Commented Apr 11, 2013 at 5:58

Your Answer

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

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