Sitemap.xml agregace, vyřešeno #2
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 03 Apr 2011 18:44:35 +0200
changeset 9 71275159d985
parent 8 ad0ee12d13fd
child 10 4e70453a027f
Sitemap.xml agregace, vyřešeno #2
build.xml
šablona/rss.xsl
šablona/sitemap.xsl
--- a/build.xml	Sun Apr 03 17:44:58 2011 +0200
+++ b/build.xml	Sun Apr 03 18:44:35 2011 +0200
@@ -21,10 +21,12 @@
 	</target>
 	
 	<target name="agregace" description="Vytvoří agregované výstupy: RSS, Atom, Sitemap.xml">
+		<!-- TODO: sloučit, zjednodušit, parametrizovat -->
+	
 		<!-- Atom -->
 		<xslt in="${vstup}/web.conf" out="${výstup}/atom.xml" style="${šablona}/atom.xsl">
 			<classpath location="/usr/share/java/saxonb-9.0.jar"/>
-			<classpath location="${funkce}"/>			
+			<classpath location="${funkce}"/>
 			<factory name="net.sf.saxon.TransformerFactoryImpl">
 				<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>				
 			</factory>
@@ -33,13 +35,20 @@
 		<!-- 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}"/>			
+			<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 -->
+		<xslt in="${výstup}/atom.xml" out="${výstup}/sitemap.xml" style="${šablona}/sitemap.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>
 		
 	</target>
 	
--- a/šablona/rss.xsl	Sun Apr 03 17:44:58 2011 +0200
+++ b/šablona/rss.xsl	Sun Apr 03 18:44:35 2011 +0200
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet version="2.0"
 	xmlns:a="http://www.w3.org/2005/Atom"
+	xmlns:atom="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"/>
 	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/šablona/sitemap.xsl	Sun Apr 03 18:44:35 2011 +0200
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="2.0"
+	xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
+	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"
+	exclude-result-prefixes="fn g j a">
+	<xsl:output	method="xml" indent="yes" encoding="UTF-8"/>
+	
+	<xsl:template match="/">
+		<urlset>
+			<xsl:apply-templates select="a:feed/a:entry"/>
+		</urlset>
+	</xsl:template>
+	
+	<xsl:template match="a:entry">
+		<url>
+			<loc><xsl:value-of select="a:link/@href"/></loc>
+			<lastmod><xsl:value-of select="a:updated"/></lastmod>
+		</url>
+	</xsl:template>
+	
+</xsl:stylesheet>