Need help to store raw data (html code) in a page


I have a private xwiki with authentication and I need to share a public RSS feed to avoid authentication stuff.
The way I try is to share a public space (read for non authenticate user) and generate periodicely a flat RSS page.
I customize velocity code of Main.Rss page, my Rss client (thunderbird) didn’t manage to refresh rss feed entries.

If I check my flat RSS page with Feed Validation Service (?xpage=plain&outputSyntax=plain), the HTML code is escaped!!!:

<p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br/>&lt;rss xmlns:dc="<span class="wikiexternallink"><a class="wikimodel-freestanding" href=""><span class="wikigeneratedlinkcontent"></span></a></span>" version="2.0"&gt;<br/>&nbsp;&nbsp;&lt;channel&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;Flux RSS des documents modifiés&lt;/title&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;link&gt;<span class="wikiexternallink"><a class="wikimodel-freestanding" href="https://xxxxxxxxxxxx/bin/view/Main/"><span class="wikigeneratedlinkcontent">

My velocity script to generate my RSS feed page ending with:

  ## =====================
  ## Execute query and generate feed
  ## =====================
  #set ($feed = $xwiki.feed.getWebFeed($queryObject.execute()))
  #set ($feedURI = $xwiki.getDocument('Main.WebHome')
  #set ($discard = $feed.setCopyright($xwiki.getXWikiPreference('copyright')))

  #set ($MyFeed = $xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0')))
  ##enregistre le feed RSS dans la page
  #set($MyPublicRSS = $xwiki.getDocument($MyPublicRSSDocName))
  #set ($discard=$MyPublicRSS.setContentType('application/rss+xml'))
  #set ($discard=$MyPublicRSS.setContent($MyFeed))
  #set ($discard=$

I think that .setContent escaping html code of <?xml version="1.0" encoding="UTF-8"?>

I tried to avoid html escaping with $xwiki.feed.getFeedOutput but without success.

How can I store raw data (html code) in a page ?

My last way I suppose is to store the HashMap $feed in a page and read it with $xwiki.feed.getFeedOutput … but how can I store $feed in a page? with $jsontool.serialize may be but how to reinject it in a hashmap variable?

Thxs for any help.

Pascal B

Several things to make sure for this kind of use case:

  • use wiki="false" in your {{velocity}} macro to be sure the result of the Velocity macro execution will stay the same
  • add ?outputSyntax=plain in the URL since by default the output syntax is XHTML (which mean that the XHTML will be escaped to look like what is described in the XDOM)

Ok ty.

It seem that my RSS feed working now even if my feed Validation Service display html code still :-/ . I use Rss?xpage=plain&outputSyntax=plain

I think my mistake was … the name of RSS feed: “updated document”.
My RSS feed reader displayed all new document and updated document IF the reader didn’t have already the RSS entry. If reader already have the RSS entry and the document is updated, RSS reader didn’t displayed new date and document version.

Then to resolve my issue, I need to generate RSS feed with few entries only 2 time per day.

But anyway, I’m still interested to know how can I store a hashmap variable in a page and reinject it in a new hashmap variable. :slight_smile: ?

xpage=plain is a bit of an old hack, better use /get/ action (instead of /view/) which I forgot to talk about in my previous message.

Maybe a better approach would be to store the RSS itself (as content of a document with syntax “plain/1.0”) instead of the RSS map (unless you plan to use this map for something else than RSS). Would also make the RSS request faster (just getting static content instead of generating it).

Yes I did that way with
#set ($discard=$MyPublicRSS.setContent("$xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0'))"))

and yes if it is possible, I plan to use the map trick (store a hashmap variable in a page and reinject it later in a new hashmap variable) for something else.