A very basic sample to create a RSS Feed for the latest 15 published documents.
The sample is based on the The Site Skeleton.
Add to the pipline of the src/site/sitemap.xmap
<!-- rss feed --> <map:match pattern="skeleton.rss"> <map:generate type="jx" src="jx/rss.xml" > <map:parameter name="target" value="{repository:files}/" /> <map:parameter name="limit" value="15" /> </map:generate> <map:transform type="webdav" /> <map:transform src="transformers/util/stripnamespaces.xsl" /> <map:transform src="transformers/common/rss.xsl" /> <map:serialize type="xml" /> </map:match>
Create a new dasl query src/site/jx/rss.xml
<request xmlns="http://hippo.nl/webdav/1.0" xmlns:d="DAV:" xmlns:hc="http://hippo.nl/cms/1.0" target="${cocoon.parameters.target}" method="SEARCH"> <body> <d:searchrequest xmlns:d="DAV:" xmlns:slide="http://jakarta.apache.org/slide/" xmlns:h="http://hippo.nl/cms/1.0"> <d:basicsearch> <d:select> <d:prop> <h:caption /> <d:displayname /> <h:type /> <h:title /> <h:publicationDate /> <h:lastModifiedBy /> <h:createdBy /> </d:prop> </d:select> <d:from> <d:scope> <d:href>content</d:href> <d:depth>infinity</d:depth> </d:scope> </d:from> <d:where> <d:and> <d:not> <d:eq> <d:prop> <h:publicationDate /> </d:prop> <d:literal></d:literal> </d:eq> </d:not> </d:and> </d:where> <d:orderby> <d:order> <d:prop> <h:publicationDate /> </d:prop> <d:descending /> </d:order> </d:orderby> <d:limit> <d:nresults>${cocoon.parameters.limit}</d:nresults> </d:limit> </d:basicsearch> </d:searchrequest> </body> </request>
Create a new stylesheet src/site/transformers/common/rss.xsl
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <rss version="2.0"> <channel> <title>Published documents</title> <link>http://live.localhost:55555/</link> <description>Shows the latest 15 published documents.</description> <xsl:apply-templates /> </channel> </rss> </xsl:template> <xsl:template match="response"> <xsl:apply-templates /> </xsl:template> <xsl:template match="status"></xsl:template> <xsl:template match="header"> <xsl:if test="@name = 'Date'"> <pubDate> <xsl:value-of select="@value" /> </pubDate> </xsl:if> </xsl:template> <xsl:template match="body"> <xsl:apply-templates /> </xsl:template> <xsl:template match="multistatus"> <xsl:for-each select="response"> <item> <xsl:apply-templates /> </item> </xsl:for-each> </xsl:template> <xsl:template match="href"> <link> <xsl:value-of select="concat( substring-before( concat('http://live.localhost:55555',substring-after(., 'content')), '.xml'), '.html')" /> </link> </xsl:template> <xsl:template match="propstat"> <xsl:if test="./prop/type = 'text'"> <xsl:apply-templates /> </xsl:if> </xsl:template> <xsl:template match="prop"> <title> <xsl:value-of select="caption" /> </title> <description> Published on <!-- Day --> <xsl:value-of select="substring(publicationDate, 7, 2)" /> <xsl:text>/</xsl:text> <!-- Month --> <xsl:value-of select="substring(publicationDate, 5, 2)" /> <xsl:text>/</xsl:text> <!-- Year --> <xsl:value-of select="substring(publicationDate, 1, 4)" /> <xsl:text> </xsl:text> <!-- Hour --> <xsl:value-of select="substring(publicationDate, 9, 2)" /> <xsl:text>:</xsl:text> <!-- Hour --> <xsl:value-of select="substring(publicationDate, 11, 2)" /> <![CDATA[<br />]]> Created by <xsl:value-of select="createdByBy" /> <![CDATA[<br />]]> Modified by <xsl:value-of select="lastModifiedBy" /> </description> </xsl:template> <xsl:template match="*" /> </xsl:stylesheet>
Point your browser/RSS reader to http://localhost:55555/skeleton.rss