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
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings">
<xsl:include href="common.xsl"/>
<xsl:param name="docurl"/>
<xsl:param name="seriestitle"/>
<xsl:param name="preferseries" select="'true'"/> <!-- Shows series when available instead of program -->
<!-- Add previous and next links for a navigation page.
BUG: If the last page has exactly $numitems, an extra "next" link
is inserted.
-->
<xsl:template name="prevnextlinks">
<xsl:param name="page" select="0"/> <!-- current page number -->
<xsl:param name="numitems" select="0"/> <!-- number of items on this page -->
<xsl:param name="maxitems" select="0"/> <!-- expected number of items per page -->
<xsl:if test="string(number($page)) != 'NaN'">
<xsl:variable name="urlprefix" select="concat(substring-before($docurl, '&sivu='), '&sivu=')"/>
<xsl:variable name="urlpostfix0" select="substring-after(substring-after($docurl, '&sivu='), '&')"/>
<xsl:variable name="urlpostfix">
<xsl:if test="urlpostfix0 != ''">
<xsl:value-of select="concat('&', urlpostfix0)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="prevurl" select="concat($urlprefix, $page - 1, $urlpostfix)"/>
<xsl:variable name="nexturl" select="concat($urlprefix, $page + 1, $urlpostfix)"/>
<!-- prev link -->
<xsl:if test="$page > 0">
<link>
<label>Edellinen</label>
<ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri($prevurl, true())"/>&param=seriestitle,<xsl:value-of select="$seriestitle"/>&param=preferseries,<xsl:value-of select="$preferseries"/>&postprocess=json2xml</ref>
</link>
</xsl:if>
<!-- next link -->
<xsl:if test="$numitems >= $maxitems">
<link>
<label>Seuraava</label>
<ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri($nexturl, true())"/>&param=seriestitle,<xsl:value-of select="$seriestitle"/>&param=preferseries,<xsl:value-of select="$preferseries"/>&postprocess=json2xml</ref>
</link>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="results/list/li">
<xsl:variable name="typeurl">
<xsl:call-template name="type_to_path">
<xsl:with-param name="type" select="dict/type"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="seriestitle2">
<xsl:choose>
<xsl:when test="dict/series/dict/name != ''">
<xsl:value-of select="dict/series/dict/name"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="dict/title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="dict/series and $preferseries = 'true'">
<!-- series link -->
<link>
<label><xsl:value-of select="$seriestitle2"/></label>
<ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://areena.yle.fi/', $typeurl, '/', dict/series/dict/id, '.json?kpl=16&sisalto=ohjelmat&sivu=0'), true())"/>&param=seriestitle,<xsl:value-of select="str:encode-uri($seriestitle2, true())"/>&param=preferseries,false&postprocess=json2xml</ref>
</link>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="streamtitle">
<xsl:choose>
<xsl:when test="dict/series/dict/name = dict/title">
<xsl:value-of select="concat(dict/title, ' osa ', dict/episodeNumber)"/>
</xsl:when>
<xsl:when test="dict/series/dict/name != ''">
<xsl:value-of select="concat(dict/series/dict/name, ': ', dict/title)"/>
</xsl:when>
<xsl:when test="starts-with(dict/title, $seriestitle)">
<xsl:value-of select="concat(dict/title, '-', dict/published)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="dict/title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<link>
<label><xsl:value-of select="$streamtitle"/></label>
<ref>wvt:///areena.yle.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://areena.yle.fi/', $typeurl, '/', dict/id, '.json'), true())"/>&param=title,<xsl:value-of select="str:encode-uri($streamtitle, true())"/>&postprocess=json2xml</ref>
<stream>wvt:///areena.yle.fi/video.xsl?srcurl=&param=title,<xsl:value-of select="str:encode-uri($streamtitle, true())"/>&param=type,<xsl:value-of select="dict/type"/>&param=id,<xsl:value-of select="dict/id"/></stream>
</link>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<wvmenu>
<title><xsl:value-of select="$seriestitle"/></title>
<xsl:apply-templates select="/jsondocument/dict/search/dict/results/list/li"/>
<xsl:call-template name="prevnextlinks">
<xsl:with-param name="page" select="number(jsondocument/dict/search/dict/params/dict/sivu)"/>
<xsl:with-param name="numitems" select="count(jsondocument/dict/search/dict/results/list/li)"/>
<xsl:with-param name="maxitems" select="number(jsondocument/dict/search/dict/params/dict/kpl)"/>
</xsl:call-template>
</wvmenu>
</xsl:template>
</xsl:stylesheet>
|