~ubuntu-branches/ubuntu/vivid/yelp-xsl/vivid-proposed

« back to all changes in this revision

Viewing changes to xslt/mallard/cache/mal-cache.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-11-29 10:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20101129100013-1fxze8fm1fegxl8w
Tags: upstream-2.31.6
ImportĀ upstreamĀ versionĀ 2.31.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, write to the
 
15
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
16
02111-1307, USA.
 
17
-->
 
18
 
 
19
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
 
20
                xmlns:mal='http://projectmallard.org/1.0/'
 
21
                xmlns:cache='http://projectmallard.org/cache/1.0/'
 
22
                xmlns='http://projectmallard.org/1.0/'
 
23
                version='1.0'>
 
24
 
 
25
<!--!!==========================================================================
 
26
Mallard Cache Files
 
27
Generate Mallard cache files from cache input files.
 
28
 
 
29
FIXME
 
30
-->
 
31
 
 
32
<xsl:output omit-xml-declaration="yes"/>
 
33
 
 
34
<xsl:include href="../common/mal-link.xsl"/>
 
35
 
 
36
 
 
37
<!--**==========================================================================
 
38
mal.cache.id
 
39
-->
 
40
<xsl:template name="mal.cache.id">
 
41
  <xsl:param name="node" select="."/>
 
42
  <xsl:param name="node_in"/>
 
43
  <xsl:attribute name="id">
 
44
    <xsl:call-template name="mal.link.linkid">
 
45
      <xsl:with-param name="node" select="$node"/>
 
46
    </xsl:call-template>
 
47
  </xsl:attribute>
 
48
</xsl:template>
 
49
 
 
50
 
 
51
<!--**==========================================================================
 
52
mal.cache.xref
 
53
-->
 
54
<xsl:template name="mal.cache.xref">
 
55
  <xsl:param name="node" select="."/>
 
56
  <xsl:param name="node_in"/>
 
57
  <xsl:attribute name="xref">
 
58
    <xsl:value-of select="$node/@xref"/>
 
59
  </xsl:attribute>
 
60
</xsl:template>
 
61
 
 
62
 
 
63
<!--**==========================================================================
 
64
mal.cache.groups
 
65
-->
 
66
<xsl:template name="mal.cache.groups">
 
67
  <xsl:param name="node" select="."/>
 
68
  <xsl:param name="node_in"/>
 
69
  <xsl:attribute name="groups">
 
70
    <xsl:value-of select="$node/@groups"/>
 
71
    <xsl:if test="not(contains(concat(' ', $node/@groups, ' '), ' #default '))">
 
72
      <xsl:text> #default</xsl:text>
 
73
    </xsl:if>
 
74
  </xsl:attribute>
 
75
</xsl:template>
 
76
 
 
77
 
 
78
<!--**==========================================================================
 
79
mal.cache.info
 
80
-->
 
81
<xsl:template name="mal.cache.info">
 
82
  <xsl:param name="node" select="."/>
 
83
  <xsl:param name="info" select="$node/mal:info"/>
 
84
  <xsl:param name="node_in"/>
 
85
  <info>
 
86
    <xsl:if test="not($info/mal:title[@type = 'link'])">
 
87
      <title type="link">
 
88
        <xsl:copy-of select="$node/mal:title/node()"/>
 
89
      </title>
 
90
    </xsl:if>
 
91
    <xsl:if test="not($info/mal:title[@type = 'sort'])">
 
92
      <title type="sort">
 
93
        <xsl:choose>
 
94
          <xsl:when test="$info/mal:title[@type = 'link']">
 
95
            <xsl:copy-of select="$info/mal:title[@type = 'link'][1]/node()"/>
 
96
          </xsl:when>
 
97
          <xsl:otherwise>
 
98
            <xsl:copy-of select="$node/mal:title/node()"/>
 
99
          </xsl:otherwise>
 
100
        </xsl:choose>
 
101
      </title>
 
102
    </xsl:if>
 
103
    <xsl:for-each select="$info/*">
 
104
      <xsl:choose>
 
105
        <xsl:when test="self::mal:link">
 
106
          <link>
 
107
            <xsl:call-template name="mal.cache.xref">
 
108
              <xsl:with-param name="node_in" select="$node_in"/>
 
109
            </xsl:call-template>
 
110
            <xsl:if test="@type = 'guide' and not(@weight)">
 
111
              <xsl:attribute name="weight">
 
112
                <xsl:text>0</xsl:text>
 
113
              </xsl:attribute>
 
114
            </xsl:if>
 
115
            <xsl:for-each select="attribute::*[not(name(.) = 'xref')] | *">
 
116
              <xsl:copy-of select="."/>
 
117
            </xsl:for-each>
 
118
          </link>
 
119
        </xsl:when>
 
120
        <xsl:otherwise>
 
121
          <xsl:copy-of select="."/>
 
122
        </xsl:otherwise>
 
123
      </xsl:choose>
 
124
    </xsl:for-each>
 
125
  </info>
 
126
</xsl:template>
 
127
 
 
128
 
 
129
<!-- == Matched Templates == -->
 
130
 
 
131
<!-- = /cache:cache = -->
 
132
<xsl:template match='/cache:cache'>
 
133
  <cache:cache>
 
134
    <xsl:for-each select="mal:page">
 
135
      <xsl:apply-templates select="document(@cache:href)/*">
 
136
        <xsl:with-param name="node_in" select="."/>
 
137
      </xsl:apply-templates>
 
138
    </xsl:for-each>
 
139
  </cache:cache>
 
140
</xsl:template>
 
141
 
 
142
<!-- = mal:page = -->
 
143
<xsl:template match="mal:page">
 
144
  <xsl:param name="node_in"/>
 
145
  <page cache:href="{$node_in/@cache:href}">
 
146
    <xsl:call-template name="mal.cache.id">
 
147
      <xsl:with-param name="node_in" select="$node_in"/>
 
148
    </xsl:call-template>
 
149
    <xsl:call-template name="mal.cache.groups">
 
150
      <xsl:with-param name="node_in" select="$node_in"/>
 
151
    </xsl:call-template>
 
152
    <xsl:if test="@type">
 
153
      <xsl:attribute name="type">
 
154
        <xsl:value-of select="@type"/>
 
155
      </xsl:attribute>
 
156
    </xsl:if>
 
157
    <xsl:call-template name="mal.cache.info">
 
158
      <xsl:with-param name="node_in" select="$node_in"/>
 
159
    </xsl:call-template>
 
160
    <xsl:apply-templates>
 
161
      <xsl:with-param name="node_in" select="$node_in"/>
 
162
    </xsl:apply-templates>
 
163
  </page>
 
164
</xsl:template>
 
165
 
 
166
<!-- = mal:section = -->
 
167
<xsl:template match="mal:section">
 
168
  <xsl:param name="node_in"/>
 
169
  <section>
 
170
    <xsl:call-template name="mal.cache.id">
 
171
      <xsl:with-param name="node_in" select="$node_in"/>
 
172
    </xsl:call-template>
 
173
    <xsl:call-template name="mal.cache.groups">
 
174
      <xsl:with-param name="node_in" select="$node_in"/>
 
175
    </xsl:call-template>
 
176
    <xsl:call-template name="mal.cache.info">
 
177
      <xsl:with-param name="node_in" select="$node_in"/>
 
178
    </xsl:call-template>
 
179
    <xsl:apply-templates>
 
180
      <xsl:with-param name="node_in" select="$node_in"/>
 
181
    </xsl:apply-templates>
 
182
  </section>
 
183
</xsl:template>
 
184
 
 
185
<!-- = mal:title = -->
 
186
<xsl:template match="mal:title">
 
187
  <xsl:copy-of select="."/>
 
188
</xsl:template>
 
189
 
 
190
<xsl:template match="node() | text()"/>
 
191
 
 
192
</xsl:stylesheet>