source: cats/ISOcat/trunk/mod-ISOcat-interface-rest/representations/atom/DC-history.xsl @ 2911

Last change on this file since 2911 was 2911, checked in by mwindhouwer, 11 years ago

M mod-ISOcat-interface-rest/representations/atom/DC-history.xsl

  • added alternate links
File size: 3.4 KB
Line 
1<?xml version="1.0"?>
2<xsl:stylesheet
3  version="2.0"
4  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5  xmlns:xs="http://www.w3.org/2001/XMLSchema"
6  xmlns:isocat="http://www.isocat.org/"
7  xmlns:dcr="http://www.isocat.org/ns/dcr"
8  xmlns:dcif="http://www.isocat.org/ns/dcif"
9  xmlns:atom="http://www.w3.org/2005/Atom"
10>
11
12        <xsl:output method="xml" encoding="utf-8"/>
13
14        <xsl:param name="props"/>
15       
16        <xsl:template match="text()"/>
17       
18        <xsl:function name="isocat:rest">
19                <xsl:param name="node"/>
20                <xsl:value-of select="$props//site"/>
21                <xsl:text>rest/dc/</xsl:text>
22                <xsl:value-of select="$node/(@id|@dc|@ref)"/>
23        </xsl:function>
24
25        <xsl:function name="isocat:link">
26                <xsl:param name="node"/>
27                <span>
28                        <xsl:text>/</xsl:text>
29                        <a href="{isocat:rest($node)}">
30                                <xsl:choose>
31                                        <xsl:when test="exists($node/@identifier)">
32                                                <xsl:value-of select="$node/@identifier"/>
33                                        </xsl:when>
34                                        <xsl:otherwise>
35                                                <xsl:value-of select="isocat:rest($node)"/>
36                                        </xsl:otherwise>
37                                </xsl:choose>
38                        </a>
39                        <xsl:text>/</xsl:text>
40                        <xsl:if test="exists($node/@name) and ($node/@name!=$node/@identifier)">
41                                <xsl:text> (</xsl:text>
42                                <xsl:value-of select="$node/@name"/>
43                                <xsl:text>)</xsl:text>
44                        </xsl:if>
45                </span>
46        </xsl:function>
47
48        <xsl:function name="isocat:title">
49                <xsl:param name="node"/>
50                <xsl:text>History of </xsl:text>
51                <xsl:value-of select="isocat:link($node)"/>
52                <xsl:text> - </xsl:text>
53                <xsl:value-of select="$node/@version"/>
54        </xsl:function>
55       
56        <xsl:template match="change">
57                <atom:entry>
58                        <atom:id>
59                                <xsl:value-of select="/history/dc/@pid"/>
60                                <xsl:text>/history#c</xsl:text>
61                                <xsl:value-of select="@isocat:id"/>
62                        </atom:id>
63                        <atom:link rel="alternate" type="text/html">
64                                <xsl:attribute name="href">
65                                        <xsl:value-of select="isocat:rest(/history/dc)"/>
66                                        <xsl:text>/history#c</xsl:text>
67                                        <xsl:value-of select="@isocat:id"/>
68                                </xsl:attribute>
69                        </atom:link>
70                        <atom:title>
71                                <xsl:text>Change by </xsl:text>
72                                <xsl:value-of select="user/name"/>
73                                <xsl:text> at </xsl:text>
74                                <xsl:value-of select="@timestamp"/>
75                        </atom:title>
76                        <atom:author>
77                                <atom:name>
78                                        <xsl:value-of select="user/name"/>
79                                </atom:name>
80                        </atom:author>
81                        <atom:updated>
82                                <xsl:value-of select="@timestamp"/>
83                        </atom:updated>
84                        <atom:content type="text">
85                                <xsl:value-of select="description"/>
86                        </atom:content>
87                </atom:entry>
88        </xsl:template>
89       
90        <xsl:template match="/history">
91                <xsl:variable name="title" select="isocat:title(dc)"/>
92                <atom:feed>
93                        <atom:id>
94                                <xsl:value-of select="dc/@pid"/>
95                        </atom:id>
96                        <atom:title type="text">
97                                <xsl:value-of select="$title"/>
98                        </atom:title>
99                        <atom:published>
100                                <xsl:value-of select="(change)[last()]/@timestamp"/>
101                        </atom:published>
102                        <xsl:if test="count(change) gt 1">
103                                <atom:updated>
104                                        <xsl:value-of select="(change)[1]/@timestamp"/>
105                                </atom:updated>
106                        </xsl:if>
107                        <atom:link rel="self" type="application/atom+xml">
108                                <xsl:attribute name="href">
109                                        <xsl:value-of select="isocat:rest(dc)"/>
110                                        <xsl:text>/history.atom</xsl:text>
111                                </xsl:attribute>
112                        </atom:link>
113                        <atom:link rel="alternate" type="text/html">
114                                <xsl:attribute name="href">
115                                        <xsl:value-of select="isocat:rest(dc)"/>
116                                        <xsl:text>/history</xsl:text>
117                                </xsl:attribute>
118                        </atom:link>
119                        <xsl:apply-templates select="change">
120                                <xsl:sort order="descending" select="@isocat:id"/>
121                        </xsl:apply-templates>
122                </atom:feed>
123        </xsl:template>
124
125</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.