RSS agregace, #2
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 03 Apr 2011 17:44:58 +0200
changeset 8 ad0ee12d13fd
parent 7 5b46493979c9
child 9 71275159d985
RSS agregace, #2
build.xml
šablona/rss.xsl
šablona/stránka.xsl
--- a/build.xml	Sun Apr 03 16:51:06 2011 +0200
+++ b/build.xml	Sun Apr 03 17:44:58 2011 +0200
@@ -30,6 +30,17 @@
 			</factory>
 		</xslt>
 		
+		<!-- RSS --> 
+		<xslt in="${výstup}/atom.xml" out="${výstup}/rss.xml" style="${šablona}/rss.xsl">			
+			<classpath location="/usr/share/java/saxonb-9.0.jar"/>
+			<classpath location="${funkce}"/>			
+			<factory name="net.sf.saxon.TransformerFactoryImpl">
+				<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>				
+			</factory>
+		</xslt>
+		
+		<!-- TODO: Sitemap.xml -->
+		
 	</target>
 	
 	<target name="kompiluj-funkce" description="">		
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/šablona/rss.xsl	Sun Apr 03 17:44:58 2011 +0200
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="2.0"
+	xmlns:a="http://www.w3.org/2005/Atom"
+	xmlns:g="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/prostor"
+	xmlns:j="java:cz.frantovo.xmlWebGenerator.Funkce"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:fn="http://www.w3.org/2005/xpath-functions"
+	xmlns:atom="http://www.w3.org/2005/Atom"
+	exclude-result-prefixes="fn g j a">
+	<xsl:output	method="xml" indent="yes" encoding="UTF-8"/>
+	
+	<xsl:template match="/">		
+		<rss version="2.0">
+			<channel>
+				<xsl:variable name="url" select="a:feed/a:link[not(@rel)]/@href"/>
+				<title><xsl:value-of select="a:feed/a:title"/></title>
+				<link><xsl:value-of select="$url"/></link>
+				<description><xsl:value-of select="a:feed/a:subtitle"/></description>				
+				<atom:link rel="self" href="{$url}rss.xml"/>
+				<xsl:apply-templates select="a:feed/a:entry"/>
+			</channel>
+		</rss>		
+	</xsl:template>
+	
+	<xsl:template match="a:entry">
+		<item>		
+			<title><xsl:value-of select="a:title"/></title>
+			<link><xsl:value-of select="a:link/@href"/></link>
+			<description><xsl:value-of select="a:summary"/></description>
+			<guid><xsl:value-of select="a:id"/></guid>
+			<pubDate><xsl:value-of select="format-dateTime(a:updated,
+                '[FNn,*-3], [D01] [MNn,*-3] [Y0001] [H01]:[m01]:[s01] [Z]',
+                'en',
+                'ISO',
+                'US')"/></pubDate>		
+		</item>
+	</xsl:template>
+	
+</xsl:stylesheet>
--- a/šablona/stránka.xsl	Sun Apr 03 16:51:06 2011 +0200
+++ b/šablona/stránka.xsl	Sun Apr 03 17:44:58 2011 +0200
@@ -19,8 +19,8 @@
 		<html>
 			<head>
 				<title><xsl:value-of select="g:stránka/g:nadpis"/></title>
-				<link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate" />
-				<link title="Novinky (RSS)" href="rss.xml" type="application/atom+xml" rel="alternate" />				
+				<link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/>
+				<link title="Novinky (RSS)"  href="rss.xml"  type="application/rss+xml"  rel="alternate"/>				
 			</head>
 			<body>
 				<xsl:apply-templates select="document(fn:encode-for-uri('../vstup/záhlaví.inc'))/g:stránka/h:text/node()"/>