-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog_articles.xslt
171 lines (160 loc) · 7.99 KB
/
blog_articles.xslt
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2009-2010, Wolfgang Keller
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:exslt="http://exslt.org/common"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="exslt msxsl">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:include href="util.xslt"/>
<xsl:include href="html.xslt"/>
<xsl:param name="type"/>
<xsl:param name="value"/>
<xsl:param name="lang"/>
<xsl:template match="/">
<xsl:call-template name="print-articles">
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
</xsl:template>
<!-- Print the articles -->
<xsl:template name="print-articles">
<xsl:param name="lang"/>
<xsl:for-each select="document('articles.xml')/articles/article">
<!-- Order articles by date and time -->
<xsl:sort order="descending" select="creation_timestamp/@year" data-type="number" />
<xsl:sort order="descending" select="creation_timestamp/@month" data-type="number" />
<xsl:sort order="descending" select="creation_timestamp/@day" data-type="number" />
<xsl:sort order="descending" select="creation_timestamp/@hours" data-type="number" />
<xsl:sort order="descending" select="creation_timestamp/@minutes" data-type="number" />
<xsl:sort order="descending" select="creation_timestamp/@seconds" data-type="number" />
<xsl:choose>
<xsl:when test="$type=''">
<xsl:call-template name="print-article">
<xsl:with-param name="origin" select="."/>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$type='category'">
<xsl:for-each select="categories/category[@id=$value]">
<xsl:call-template name="print-article">
<xsl:with-param name="origin" select="../.."/>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:when test="$type='author'">
<xsl:for-each select="authors/author[@id=$value]">
<xsl:call-template name="print-article">
<xsl:with-param name="origin" select="../.."/>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="print-article">
<xsl:param name="origin"/>
<xsl:param name="lang"/>
<div class="entry-archive">
<!-- Print title of article -->
<div class="entrytitle">
<h2>
<a href="#">
<xsl:value-of select="$origin/title"/>
</a>
</h2>
</div>
<!-- Print date of creation -->
<h3>
<xsl:call-template name="format-date">
<xsl:with-param name="year" select="$origin/creation_timestamp/@year"/>
<xsl:with-param name="month" select="$origin/creation_timestamp/@month"/>
<xsl:with-param name="day" select="$origin/creation_timestamp/@day"/>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
</h3>
<!-- Print article content -->
<div class="entrybody">
<xsl:apply-templates mode="html" select="$origin/content/*"/>
</div>
<div class="entrymeta">
<div class="postinfo">
<p>
<img src="themes/XMulti/images/User.png" class="icon">
<xsl:attribute name="alt">
<xsl:call-template name="print-string">
<xsl:with-param name="id">person</xsl:with-param>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
</xsl:attribute>
</img>
<!-- Print the names of the authors -->
<span class="postedby">
<xsl:call-template name="print-string">
<xsl:with-param name="id">recorded_by</xsl:with-param>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
<xsl:variable name="authors_root">
<xsl:call-template name="author-names-from-author-ids">
<xsl:with-param name="authors-ids" select="$origin"/>
</xsl:call-template>
</xsl:variable>
<xsl:for-each select="exslt:node-set($authors_root)/authors/author">
<xsl:call-template name="show_all_articles_of_author_a">
<xsl:with-param name="id" select="@id"/>
<xsl:with-param name="prename" select="prename"/>
<xsl:with-param name="surname" select="surname"/>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
<xsl:if test="position()!=last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</span>
<br/>
<img src="themes/XMulti/images/Folder.png" class="icon">
<xsl:attribute name="alt">
<xsl:call-template name="print-string">
<xsl:with-param name="id">folder</xsl:with-param>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
</xsl:attribute>
</img>
<span class="filedto">
<xsl:call-template name="print-string">
<xsl:with-param name="id">filed_to</xsl:with-param>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
<xsl:variable name="categories_root">
<xsl:call-template name="category-names-from-category-ids">
<xsl:with-param name="category-ids" select="$origin"/>
</xsl:call-template>
</xsl:variable>
<xsl:for-each select="exslt:node-set($categories_root)/categories/category">
<xsl:call-template name="show_all_articles_of_category_a">
<xsl:with-param name="id" select="@id"/>
<xsl:with-param name="category" select="."/>
<xsl:with-param name="lang" select="$lang"/>
</xsl:call-template>
<xsl:if test="position()!=last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</span>
</p>
<p> </p>
</div>
</div>
</div>
</xsl:template>
</xsl:stylesheet>