You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2008/03/30 00:59:24 UTC

svn commit: r642649 - in /lenya/sandbox/modules/feed: sitemap.xmap xslt/atom2collection.xsl xslt/atom2include.xsl xslt/atom2rss.xsl xslt/atom2xhtml.xsl

Author: andreas
Date: Sat Mar 29 16:59:24 2008
New Revision: 642649

URL: http://svn.apache.org/viewvc?rev=642649&view=rev
Log:
Adding RSS generation to feed module.

Added:
    lenya/sandbox/modules/feed/xslt/atom2include.xsl
    lenya/sandbox/modules/feed/xslt/atom2rss.xsl
    lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl
Modified:
    lenya/sandbox/modules/feed/sitemap.xmap
    lenya/sandbox/modules/feed/xslt/atom2collection.xsl

Modified: lenya/sandbox/modules/feed/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/feed/sitemap.xmap?rev=642649&r1=642648&r2=642649&view=diff
==============================================================================
--- lenya/sandbox/modules/feed/sitemap.xmap (original)
+++ lenya/sandbox/modules/feed/sitemap.xmap Sat Mar 29 16:59:24 2008
@@ -30,16 +30,14 @@
 
     <map:pipeline>
       
-      <!-- {1:format}/{2:feedUrl}-->
+      <!-- {1:sourceFormat}/{3:feedUrl} -->
       <map:match pattern="*/**">
         <map:generate src="{2}"/>
-        <map:transform src="xslt/{1}2collection.xsl">
-          <map:parameter name="language" value="{5}"/>
-        </map:transform>
+        <map:transform src="xslt/{1}2{request-param:format}.xsl"/>
         <map:transform type="unescape"/>
         <map:transform src="xslt/addXhtmlNamespace.xsl"/>
         <map:transform type="i18n">
-          <map:parameter name="locale" value="{5}"/>
+          <map:parameter name="locale" value="{page-envelope:document-language}"/>
         </map:transform>
         <map:serialize type="xml"/>
       </map:match>

Modified: lenya/sandbox/modules/feed/xslt/atom2collection.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/feed/xslt/atom2collection.xsl?rev=642649&r1=642648&r2=642649&view=diff
==============================================================================
--- lenya/sandbox/modules/feed/xslt/atom2collection.xsl (original)
+++ lenya/sandbox/modules/feed/xslt/atom2collection.xsl Sat Mar 29 16:59:24 2008
@@ -20,11 +20,10 @@
   xmlns:col="http://apache.org/cocoon/lenya/collection/1.0"
   xmlns:atom='http://www.w3.org/2005/Atom'
   xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
-  xmlns:meta="http://apache.org/cocoon/lenya/metadata/1.0"
-  xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:xhtml="http://www.w3.org/1999/xhtml"
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns:rss="http://apache.org/lenya/rss/2.0"
   xmlns:unescape="http://apache.org/lenya/unescape/1.0"
   exclude-result-prefixes="atom openSearch">
   
@@ -46,21 +45,18 @@
       </xsl:choose>
     </xsl:variable>
     <col:document href="{atom:link[@type = 'text/html']/@href}" xml:lang="{$language}">
-      <meta:metadata>
-        <dc:elements>
-          <dc:date>
-            <i18n:date-time src-pattern="yyyy-MM-dd'T'HH:mm:ss.S Z" pattern="yyyy-MM-dd HH:mm:ss">
-              <xsl:text/>
-              <xsl:value-of select="substring(atom:published, 1, 23)"/>
-              <xsl:text> </xsl:text>
-              <xsl:value-of select="substring(atom:published, 24, 3)"/>
-              <xsl:value-of select="substring(atom:published, 28, 2)"/>
-              <xsl:text/>
-            </i18n:date-time>
-          </dc:date>
-          <dc:title><xsl:value-of select="atom:title"/></dc:title>
-        </dc:elements>
-      </meta:metadata>
+      <rss:item>
+        <rss:title><xsl:value-of select="atom:title"/></rss:title>
+        <rss:pubDate><i18n:date-time src-pattern="yyyy-MM-dd'T'HH:mm:ss.S Z" pattern="yyyy-MM-dd HH:mm:ss">
+          <xsl:text/>
+          <xsl:value-of select="substring(atom:published, 1, 23)"/>
+          <xsl:text> </xsl:text>
+          <xsl:value-of select="substring(atom:published, 24, 3)"/>
+          <xsl:value-of select="substring(atom:published, 28, 2)"/>
+          <xsl:text/>
+        </i18n:date-time></rss:pubDate>
+      </rss:item>
+      <!--
       <html>
         <body>
           <p>
@@ -70,6 +66,7 @@
           </p>
         </body>
       </html>
+      -->
     </col:document>
   </xsl:template>
   

Added: lenya/sandbox/modules/feed/xslt/atom2include.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/feed/xslt/atom2include.xsl?rev=642649&view=auto
==============================================================================
--- lenya/sandbox/modules/feed/xslt/atom2include.xsl (added)
+++ lenya/sandbox/modules/feed/xslt/atom2include.xsl Sat Mar 29 16:59:24 2008
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  
+  <xsl:import href="fallback://lenya/modules/feed/xslt/atom2xhtml.xsl"/>
+
+</xsl:stylesheet>
\ No newline at end of file

Added: lenya/sandbox/modules/feed/xslt/atom2rss.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/feed/xslt/atom2rss.xsl?rev=642649&view=auto
==============================================================================
--- lenya/sandbox/modules/feed/xslt/atom2rss.xsl (added)
+++ lenya/sandbox/modules/feed/xslt/atom2rss.xsl Sat Mar 29 16:59:24 2008
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+  xmlns:col="http://apache.org/cocoon/lenya/collection/1.0"
+  xmlns:atom='http://www.w3.org/2005/Atom'
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  exclude-result-prefixes="atom">
+  
+  <xsl:param name="defaultLanguage" select="'en'"/>
+  
+  
+  <xsl:template match="atom:feed">
+    <col:collection>
+      <xsl:apply-templates select="atom:entry"/>
+    </col:collection>
+  </xsl:template>
+  
+  
+  <xsl:template match="atom:entry">
+    <xsl:variable name="language">
+      <xsl:choose>
+        <xsl:when test="atom:content/@xml:lang"><xsl:value-of select="atom:content/@xml:lang"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$defaultLanguage"/></xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <col:document href="{atom:link[@type = 'text/html']/@href}" xml:lang="{$language}">
+      <item>
+        <title><xsl:value-of select="atom:title"/></title>
+        <description><xsl:value-of select="atom:summary"/></description>
+        <link><xsl:value-of select="atom:link/@href"/></link>
+        <author><xsl:value-of select="atom:author/atom:name"/>/></author>
+        <pubDate><i18n:date-time src-pattern="yyyy-MM-dd'T'HH:mm:ss.S Z" pattern="yyyy-MM-dd HH:mm:ss"
+          value="{substring(atom:published, 1, 23)} {substring(atom:published, 24, 3)}{substring(atom:published, 28, 2)}"/></pubDate>
+      </item>
+    </col:document>
+  </xsl:template>
+  
+
+</xsl:stylesheet>
\ No newline at end of file

Added: lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl?rev=642649&view=auto
==============================================================================
--- lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl (added)
+++ lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl Sat Mar 29 16:59:24 2008
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+  xmlns:col="http://apache.org/cocoon/lenya/collection/1.0"
+  xmlns:atom='http://www.w3.org/2005/Atom'
+  xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns:rss="http://apache.org/lenya/rss/2.0"
+  xmlns:unescape="http://apache.org/lenya/unescape/1.0"
+  xmlns:dc="http://purl.org/dc/elements/1.1/"
+  exclude-result-prefixes="atom openSearch">
+  
+  <xsl:param name="defaultLanguage" select="'en'"/>
+  
+  
+  <xsl:template match="atom:feed">
+    <col:collection>
+      <xsl:apply-templates select="atom:entry"/>
+    </col:collection>
+  </xsl:template>
+  
+  
+  <xsl:template match="atom:entry">
+    <xsl:variable name="language">
+      <xsl:choose>
+        <xsl:when test="atom:content/@xml:lang"><xsl:value-of select="atom:content/@xml:lang"/></xsl:when>
+        <xsl:otherwise><xsl:value-of select="$defaultLanguage"/></xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <col:document href="{atom:link[@type = 'text/html']/@href}" xml:lang="{$language}">
+      <dc:title><xsl:value-of select="atom:title"/></dc:title>
+      <dc:date><i18n:date-time src-pattern="yyyy-MM-dd'T'HH:mm:ss.S Z" pattern="yyyy-MM-dd HH:mm:ss">
+        <xsl:text/>
+        <xsl:value-of select="substring(atom:published, 1, 23)"/>
+        <xsl:text> </xsl:text>
+        <xsl:value-of select="substring(atom:published, 24, 3)"/>
+        <xsl:value-of select="substring(atom:published, 28, 2)"/>
+        <xsl:text/>
+      </i18n:date-time></dc:date>
+      <html>
+        <body>
+          <p>
+            <unescape:unescape>
+              <xsl:apply-templates select="atom:content/text()"/>
+            </unescape:unescape>
+          </p>
+        </body>
+      </html>
+    </col:document>
+  </xsl:template>
+  
+
+</xsl:stylesheet>
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org