3

I have a Schema with some RTF fields in it. I need to provide a RSS feed for Components based on this Schema.

The problem is, the RTF fields contain some HTML markup and inline Component links (sometimes to multimedia Components - PDFs, images etc.). To satisfy the requirements I need to maintain these links in the RSS feed. Upon publishing I can see tags with tridion:href which are then resolved on the presentation side to regular links.

How do I parse/escape these links or any HTML content to make it XML compliant (replace < & > with &lt; & &gt; and similar)?

I am using SDL Tridion 2011 SP1 and Java on the presentation side.

2 Answers 2

4

Escaping would be a way as @user978511 suggests, but RSS feeds are valid XML, so you can simply keep the tridion:href attribute in your links as long as you add the appropriate namespace to your XML.

The correct namespace for the tridion prefix would be http://www.tridion.com/ContentManager/5.0, you can add that to the rss root element of your feed XML:

<?xml version="1.0" ?>
<rss version="2.0" xmlns:tridion="http://www.tridion.com/ContentManager/5.0">
    ...
</rss>

Update

You will need to adjust your Component/Page Template to keep the tridion:href attribute from being resolved. Most likely you currently have the Default Finish Actions Template Building Block in your Component Template, which contains the Link Resolver TBB, and that is responsible for resolving the link.

If you require a specific output, you have to create a custom Component Template (and possibly also a custom Page Template with that) to ensure you meet your requirements.

1
  • Thanks Bart, but the problem is the tridion:href attribute gets transformed into an actual HTML a:href after publishing which invalidates the XML. Jan 14, 2014 at 9:26
3

The easiest way is to apply XSLT transformation to it. You can google a bit and find something like: https://stackoverflow.com/questions/1162352/converting-xml-to-escaped-text-in-xslt https://stackoverflow.com/questions/12773334/html-escape-some-xml-tag-using-xslt

Just pick the most appropriate

1
  • Thanks for the quick response. Is there a way to do this without using XSLT? Jan 14, 2014 at 9:20

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.