Debian Codegraph @

xslt/mallard/cache/mal-cache.xsl

raw
1 <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
2 <!--
3 This program is free software; you can redistribute it and/or modify it under
4 the terms of the GNU Lesser General Public License as published by the Free
5 Software Foundation; either version 2 of the License, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful, but WITHOUT
9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 details.
12
13 You should have received a copy of the GNU Lesser General Public License
14 along with this program; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/>.
15 -->
16
17 <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
18 xmlns:mal='http://projectmallard.org/1.0/'
19 xmlns:cache='http://projectmallard.org/cache/1.0/'
20 xmlns:site='http://projectmallard.org/site/1.0/'
21 xmlns='http://projectmallard.org/1.0/'
22 version='1.0'>
23
24 <!--!!==========================================================================
25 Mallard Cache Files
26 Generate Mallard cache files from cache input files.
27
28 FIXME
29 -->
30
31 <xsl:output omit-xml-declaration="yes"/>
32
33 <xsl:include href="../common/mal-link.xsl"/>
34
35
36 <!--**==========================================================================
37 mal.cache.id
38 -->
39 <xsl:template name="mal.cache.id">
40 <xsl:param name="node" select="."/>
41 <xsl:param name="node_in"/>
42 <xsl:attribute name="id">
43 <xsl:call-template name="mal.link.linkid">
44 <xsl:with-param name="node" select="$node"/>
45 </xsl:call-template>
46 </xsl:attribute>
47 </xsl:template>
48
49
50 <!--**==========================================================================
51 mal.cache.info
52 -->
53 <xsl:template name="mal.cache.info">
54 <xsl:param name="node" select="."/>
55 <xsl:param name="info" select="$node/mal:info"/>
56 <xsl:param name="node_in"/>
57 <info>
58 <xsl:for-each select="$info/*">
59 <xsl:choose>
60 <xsl:when test="$node/parent::mal:stack[@type = 'series'] and
61 self::mal:link[@type = 'next']"/>
62 <xsl:otherwise>
63 <xsl:copy-of select="."/>
64 </xsl:otherwise>
65 </xsl:choose>
66 </xsl:for-each>
67 <xsl:if test="$node/parent::mal:stack[@type = 'series']">
68 <xsl:variable name="next" select="$node/following-sibling::mal:page[1]"/>
69 <xsl:if test="$next">
70 <link type="next" xref="{$next/@id}"/>
71 </xsl:if>
72 </xsl:if>
73 </info>
74 </xsl:template>
75
76
77 <!-- == Matched Templates == -->
78
79 <!-- = /cache:cache = -->
80 <xsl:template match='/cache:cache'>
81 <cache:cache>
82 <xsl:for-each select="mal:page | mal:stack">
83 <xsl:apply-templates select="document(@cache:href)/*">
84 <xsl:with-param name="node_in" select="."/>
85 </xsl:apply-templates>
86 </xsl:for-each>
87 </cache:cache>
88 </xsl:template>
89
90 <!-- = mal:stack = -->
91 <xsl:template match="mal:stack">
92 <xsl:param name="node_in"/>
93 <xsl:apply-templates select="mal:page">
94 <xsl:with-param name="node_in" select="$node_in"/>
95 </xsl:apply-templates>
96 </xsl:template>
97
98 <!-- = mal:page = -->
99 <xsl:template match="mal:page">
100 <xsl:param name="node_in"/>
101 <page>
102 <xsl:copy-of select="@*"/>
103 <xsl:copy-of select="$node_in/@cache:*"/>
104 <xsl:copy-of select="$node_in/@site:*"/>
105 <xsl:call-template name="mal.cache.id">
106 <xsl:with-param name="node_in" select="$node_in"/>
107 </xsl:call-template>
108 <xsl:call-template name="mal.cache.info">
109 <xsl:with-param name="node_in" select="$node_in"/>
110 </xsl:call-template>
111 <xsl:apply-templates>
112 <xsl:with-param name="node_in" select="$node_in"/>
113 </xsl:apply-templates>
114 </page>
115 </xsl:template>
116
117 <!-- = mal:section = -->
118 <xsl:template match="mal:section">
119 <xsl:param name="node_in"/>
120 <section>
121 <xsl:copy-of select="@*"/>
122 <xsl:call-template name="mal.cache.id">
123 <xsl:with-param name="node_in" select="$node_in"/>
124 </xsl:call-template>
125 <xsl:call-template name="mal.cache.info">
126 <xsl:with-param name="node_in" select="$node_in"/>
127 </xsl:call-template>
128 <xsl:apply-templates>
129 <xsl:with-param name="node_in" select="$node_in"/>
130 </xsl:apply-templates>
131 </section>
132 </xsl:template>
133
134 <!-- = mal:title = -->
135 <xsl:template match="mal:title">
136 <xsl:copy-of select="."/>
137 </xsl:template>
138
139 <xsl:template match="node() | text()"/>
140
141 </xsl:stylesheet>