aboutsummaryrefslogtreecommitdiff
path: root/source/99_result/atom.xsl
blob: da7f370f45435ee3bf66cdb69890563f458c299c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>

<xsl:output
	method="xml"
	omit-xml-declaration="no"
	encoding="UTF-8"
	indent="no"
/>

<xsl:variable name="meta">
	<datasource type="main"    mode="full" source="target/02_data/articles.xml" target="articles"/>
	<datasource type="support" mode="full" source="target/03_meta/meta.xml"     target="meta"/>
	<target     mode="plain"   value="atom.xml"/> 
</xsl:variable>

<xsl:variable name="url" select="datasource/meta/url"/>

<xsl:template match="*" mode="xhtml_copy">
	<xsl:element name="{name()}" namespace="http://www.w3.org/1999/xhtml">
		<xsl:apply-templates select="@*|node()" mode="xhtml_copy" />
	</xsl:element>
</xsl:template>

<xsl:template match="@*|text()|comment()" mode="xhtml_copy">
	<xsl:copy/>
</xsl:template>

<xsl:template match="/">
	<feed xmlns="http://www.w3.org/2005/Atom">
		<id><xsl:value-of select="$url"/></id>
		<title><xsl:value-of select="datasource/meta/title"/></title>
		<author>
			<name>Adrian Kummerländer</name>
		</author>

		<xsl:apply-templates select="datasource/articles/entry[position() &lt;= 5]"/>
	</feed>
</xsl:template>

<xsl:template match="datasource/articles/entry">
	<entry xmlns="http://www.w3.org/2005/Atom">
		<title><xsl:value-of select="title"/></title>
		<link><xsl:value-of select="$url"/>/article/<xsl:value-of select="@handle"/></link>
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
				<xsl:apply-templates mode="xhtml_copy" select="content/node()" />
			</div>
		</content>
		<updated>
			<xsl:value-of select="date/full"/>
			<xsl:text>T00:00:01+02:00</xsl:text>
		</updated>
	</entry>
</xsl:template>

</xsl:stylesheet>