I'm trying to put some HTML content inside <content:encoded>
tags using ROME and its modules. So far I've succesfully put mediaRSS and geoRSS in the feed, but my content is not showing up.
Here's my code:
ContentModule contentModule = new ContentModuleImpl();
List<ContentItem> contents = new ArrayList<ContentItem>();
List<String> contentValueDOM = new ArrayList<String>();
ContentItem content = new ContentItem();
content.setContentValue("<p>Some text here</p>");
content.setContentEncoding("text/html");
content.setContentAbout("Paragraph");
content.setContentValueDOM(contentValueDOM);
contents.add(content);
contentModule.setContents(contents);
contentModule.setContentItems(contents);
entry.getModules().add(contentModule);
And here is my output
<item>
<title>Example page</title>
<link>http://www.example.com/news/2012/march/example-page.html</link>
<description>Introduction</description>
<category>news</category>
<pubDate>Tue, 27 Mar 2012 08:18:52 GMT</pubDate>
<guid>http://www.example.com/news/2012/march/example-page.html</guid>
<dc:date>2012-03-27T08:18:52Z</dc:date>
<content:items>
<rdf:Bag>
<rdf:li>
<content:item rdf:about="Paragraph">
<content:encoding rdf:resource="text/html" />
<rdf:value />
</content:item>
</rdf:li>
</rdf:Bag>
</content:items>
<geo:lat>52.09161879618039</geo:lat>
<geo:long>5.1141280958007655</geo:long>
<media:content medium="image" fileSize="16029" height="500" type="image/jpeg" width="399" url="http://www.example.com/binaries/content/gallery/image.jpg">
<media:description type="plain/text" />
<media:thumbnail url="http://www.example.com/binaries/content/gallery/thumbnail/image.jpg" />
</media:content>
<media:content medium="video" expression="full" type="application/x-shockwave-flash" isDefault="true" url="http://www.youtube.com/v/jQq4ju-vupY?rel=0">
<media:player url="http://www.youtube.com/v/jQq4ju-vupY?rel=0&feature=youtube_gdata_player" width="520" height="390" />
</media:content>
</item>
This seems to work:
However the above outputs the feed using the Updated Syntax rather than the Original Syntax. With the Updated Syntax you get something that looks like (this contains the <content:encoded> tag):
When I tried to use the ContentItem which does support Original Syntax (using modules-0.3.2) like you did I found that the ContentModuleGenerator required that setContentValueDOM contains the value of the content to output. It also appears that this content needs to be castable to org.jdom.Content (e.g. you need to call setContentValueDOM(List<org.jdom.Content>)). As org.jdom.CDATA is a subclass of org.jdom.Content you can do something like this:
which produces:
If you alter the above code sample replacing the CDATA section with an Element and adding appropriate format and encoding information thus:
you will end up with XML showing the <content:encoding> tag: