Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
Thanks Bart, but the problem is the tridion:href attribute gets transformed into an actual HTML a:href after publishing which invalidates the XML. –  hzahid Jan 14 at 9:26
add comment

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

Just pick the most appropriate

share|improve this answer
    
Thanks for the quick response. Is there a way to do this without using XSLT? –  hzahid Jan 14 at 9:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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