/[volute]/trunk/projects/vocabularies/doc/structure.xslt
ViewVC logotype

Contents of /trunk/projects/vocabularies/doc/structure.xslt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 58 - (show annotations)
Sun Feb 10 22:14:45 2008 UTC (12 years, 9 months ago) by norman.x.gray
File size: 13428 byte(s)
Reworking vocabset-5 issue, following list discussions
Fix editors in std:ucdmaint ref
Styling tweaks: add fancy '[link here]' link in generated XHTML

1 <?xml version="1.0" encoding="UTF-8"?>
2 <x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform"
3 version="1.0"
4 exclude-result-prefixes="h"
5 xmlns:h="http://www.w3.org/1999/xhtml"
6 xmlns:dc="http://purl.org/dc/elements/1.1/"
7 xmlns:dcterms="http://purl.org/dc/terms/">
8 <x:output method="xml"
9 encoding="UTF-8"
10 version="1.0"
11 omit-xml-declaration="yes"/>
12
13 <!-- This namespace-alias appears to terminally confuse libxslt 10111,
14 causing it to spin its wheels endlessly when processing the
15 <h:html> element, though bizarrely not any children of it
16 (libxslt 10122 is OK, though).
17 I can't remember why it's here, and it seems redundant,
18 but I'd probably best leave it here until it becomes definitely
19 redundant, or explicably necessary. -->
20 <!--<x:namespace-alias stylesheet-prefix="h" result-prefix="#default"/>-->
21
22 <!-- In the templates below, there are numerous references to <x:element>,
23 adding elements in the xhtml namespage. These should be replaceable
24 by simple h:blah elements, but doing so appears to confuse at least
25 one XSLT processor (I think libxslt 10111). -->
26
27 <x:param name="target"/>
28
29 <x:param name="document-id">document-id</x:param>
30
31 <!-- default identity transformation -->
32 <x:template match="node()|@*">
33 <x:copy>
34 <x:apply-templates select="node()|@*"/>
35 </x:copy>
36 </x:template>
37
38 <!-- process root node -->
39 <x:template match="/">
40 <x:choose>
41 <x:when test="$target='aux'">
42 <x:apply-templates select="//processing-instruction('bibliography')"
43 mode="extract-aux"/>
44 </x:when>
45 <x:when test="$target">
46 <x:message terminate="yes">Unrecognised target <x:value-of select="$target"/>
47 </x:message>
48 </x:when>
49 <x:otherwise>
50 <x:apply-templates/>
51 </x:otherwise>
52 </x:choose>
53 </x:template>
54
55 <!-- Add the GRDDL transformation magic attribute to the HTML element -->
56 <x:template xmlns:grddl="http://www.w3.org/2003/g/data-view#" match="h:html">
57 <x:copy>
58 <x:attribute name="grddl:transformation"
59 >http://ns.inria.fr/grddl/rdfa/2007/05/25/RDFa2RDFXML.xsl</x:attribute>
60 <x:apply-templates/>
61 </x:copy>
62 </x:template>
63
64 <x:template match="h:head">
65 <x:copy>
66 <x:apply-templates select="@*"/>
67 <x:copy-of select="namespace::*[.='http://purl.org/dc/elements/1.1/']"/>
68 <x:choose>
69 <x:when test="h:link[@rel='stylesheet']">
70 <x:comment>Using stylesheet from source file</x:comment>
71 <x:apply-templates select="h:link[@rel='stylesheet']"/>
72 </x:when>
73 <x:otherwise>
74 <x:element name='link' namespace='http://www.w3.org/1999/xhtml'>
75 <x:attribute name='rel'>stylesheet</x:attribute>
76 <x:attribute name='type'>text/css</x:attribute>
77 <x:attribute name='href'>/style/base.css</x:attribute>
78 </x:element>
79 <!--h:link rel="stylesheet" type="text/css" href="/style/base.css"/-->
80 </x:otherwise>
81 </x:choose>
82 <x:apply-templates select="h:title|h:meta|h:style"/>
83 </x:copy>
84 </x:template>
85
86 <x:template match="h:div[@class='section' or @class='section-nonum']">
87 <x:variable name="id">
88 <x:call-template name="make-section-id"/>
89 </x:variable>
90 <x:variable name="level">
91 <x:choose>
92 <x:when test="ancestor::h:div[@class='section']/ancestor::h:div[@class='section']">h4</x:when>
93 <x:when test="ancestor::h:div[@class='section']">h3</x:when>
94 <x:otherwise>h2</x:otherwise>
95 </x:choose>
96 </x:variable>
97 <x:element name="{$level}" namespace='http://www.w3.org/1999/xhtml'>
98 <x:if test="@id">
99 <x:attribute name='class'>hlink</x:attribute>
100 </x:if>
101 <x:apply-templates select="." mode="make-section-name"/>
102 <x:element name='a' namespace='http://www.w3.org/1999/xhtml'>
103 <x:attribute name='name'><x:value-of select='$id'/></x:attribute>
104 <x:if test="@id">
105 <!-- If the id attribute is present, then add the
106 [link here] text, providing a link for this section -->
107 <x:attribute name='href'>#<x:value-of select='$id'/></x:attribute>
108 <x:text> [link here]</x:text>
109 </x:if>
110 </x:element>
111 </x:element>
112 <!--
113 <x:element name="{$level}" namespace='http://www.w3.org/1999/xhtml'>
114 <x:attribute name='class'>hlink</x:attribute>
115 <x:element name="a" namespace='http://www.w3.org/1999/xhtml'>
116 <x:attribute name='name'><x:value-of select='$id'/></x:attribute>
117 <x:apply-templates select="." mode="make-section-name"/>
118 </x:element>
119 <x:element name='a' namespace='http://www.w3.org/1999/xhtml'>
120 <x:attribute name='href'>#<x:value-of select='$id'/></x:attribute>
121 <x:text> [link here]</x:text>
122 </x:element>
123 </x:element>
124 -->
125 <x:apply-templates/>
126 </x:template>
127
128 <x:template match="h:p[@class='title']"/>
129
130 <x:template match="h:div[@class='appendices']">
131 <x:element name='h2' namespace='http://www.w3.org/1999/xhtml'>Appendices</x:element>
132 <x:apply-templates/>
133 </x:template>
134
135 <x:template match="h:div" mode="make-toc">
136 <x:variable name="id">
137 <x:call-template name="make-section-id"/>
138 </x:variable>
139 <x:element name='li' namespace='http://www.w3.org/1999/xhtml'>
140 <x:element name='a' namespace='http://www.w3.org/1999/xhtml'>
141 <x:attribute name='href'>#<x:value-of select='$id'/></x:attribute>
142 <x:apply-templates select="." mode="make-section-name"/>
143 </x:element>
144 <x:if test="h:div[@class='section' or @class='section-nonum']">
145 <x:element name='ul' namespace='http://www.w3.org/1999/xhtml'>
146 <x:apply-templates select="h:div[@class='section' or @class='section-nonum']" mode="make-toc"/>
147 </x:element>
148 </x:if>
149 </x:element>
150 </x:template>
151
152 <x:template match="processing-instruction('toc')">
153 <x:element name='div' namespace='http://www.w3.org/1999/xhtml'>
154 <x:attribute name='id'>toc</x:attribute>
155 <x:attribute name='class'>toc</x:attribute>
156 <x:element name='ul' namespace='http://www.w3.org/1999/xhtml'>
157 <x:apply-templates select="//h:body/h:div[@class='section' or @class='section-nonum']|//h:body/h:div[@class='appendices']/h:div" mode="make-toc"/>
158 </x:element>
159 </x:element>
160 </x:template>
161
162 <x:template name="make-section-id">
163 <x:choose>
164 <x:when test="@id">
165 <x:value-of select="@id"/>
166 </x:when>
167 <x:otherwise>
168 <x:value-of select="generate-id()"/>
169 </x:otherwise>
170 </x:choose>
171 </x:template>
172
173 <x:template match="h:div" mode="make-section-name">
174 <x:choose>
175 <x:when test="ancestor-or-self::h:div[@class='section-nonum']"/>
176 <x:when test="ancestor::h:div[@class='appendices']">
177 <x:number count="h:div[@class='section']" level="multiple" format="A.1"/>
178 <x:text> </x:text>
179 </x:when>
180 <x:otherwise>
181 <x:number count="h:div[@class='section']" level="multiple" format="1.1"/>
182 <x:text> </x:text>
183 </x:otherwise>
184 </x:choose>
185 <x:apply-templates select="h:p[@class='title']/text()"/>
186 </x:template>
187
188 <x:template match="processing-instruction('bibliography')">
189 <x:copy-of select="document(concat(substring-before($document-id, '.xml'),'.bbl'))"/>
190 </x:template>
191
192 <x:template match="h:span[@class='cite']">
193 <x:element name='em' namespace='http://www.w3.org/1999/xhtml'>
194 <x:text>[</x:text>
195 <x:element name='a' namespace='http://www.w3.org/1999/xhtml'>
196 <x:attribute name="href">#ref:<x:value-of select="."/></x:attribute>
197 <x:value-of select="."/>
198 </x:element>
199 <x:text>]</x:text>
200 </x:element>
201 </x:template>
202
203 <x:template match="h:span[@class='url']">
204 <x:element name='a' namespace='http://www.w3.org/1999/xhtml'>
205 <x:attribute name='href'><x:value-of select='.'/></x:attribute>
206 <x:element name='span' namespace='http://www.w3.org/1999/xhtml'>
207 <x:attribute name='class'>url</x:attribute>
208 <x:value-of select="."/>
209 </x:element>
210 </x:element>
211 </x:template>
212
213 <x:template match="processing-instruction('bibliography')" mode="extract-aux">
214 <x:text>\relax
215 </x:text>
216 <x:apply-templates select="//h:span[@class='cite']" mode="extract-aux"/>
217 <x:if test="string-length(.) &gt; 0">
218 <x:call-template name="make-tex-command">
219 <x:with-param name="command">bibdata</x:with-param>
220 <x:with-param name="content">
221 <x:value-of select="normalize-space(.)"/>
222 </x:with-param>
223 </x:call-template>
224 </x:if>
225 </x:template>
226
227 <x:template match="h:span[@class='cite']" mode="extract-aux">
228 <x:call-template name="make-tex-command">
229 <x:with-param name="command">citation</x:with-param>
230 <x:with-param name="content">
231 <x:copy-of select="."/>
232 </x:with-param>
233 </x:call-template>
234 </x:template>
235
236 <x:key name="xrefs" match="h:div" use="@id"/>
237
238 <x:template match="h:span[@class='xref']">
239 <x:variable name="id" select="."/>
240 <x:element name='a' namespace='http://www.w3.org/1999/xhtml'>
241 <x:attribute name='href'>#<x:value-of select='$id'/></x:attribute>
242 <x:text>Sect. </x:text>
243 <x:apply-templates select="key('xrefs',$id)" mode="make-section-name"/>
244 </x:element>
245 </x:template>
246
247 <x:template match="h:span[@class='rcsinfo']">
248 <x:value-of select="substring-before(substring-after(.,': '),' $')"/>
249 </x:template>
250
251 <x:template match="h:h1">
252 <x:element name='h1' namespace='http://www.w3.org/1999/xhtml'>
253 <x:attribute name='property'>dc:title</x:attribute>
254 <x:apply-templates select="@*"/>
255 <x:apply-templates/>
256 </x:element>
257 </x:template>
258
259 <x:template xmlns:owl="http://www.w3.org/2002/07/owl#" match="h:meta">
260 <x:choose>
261 <x:when test="@name='DC.rights'">
262 <x:element name='link' namespace='http://www.w3.org/1999/xhtml'>
263 <x:attribute name='about'/>
264 <x:attribute name="rel">
265 <x:value-of select="@name"/>
266 </x:attribute>
267 <x:attribute name="href">
268 <x:value-of select="@content"/>
269 </x:attribute>
270 </x:element>
271 </x:when>
272 <x:when test="@name='rcsdate'">
273 <x:element name='meta' namespace='http://www.w3.org/1999/xhtml'>
274 <x:attribute name='property'>dcterms:modified</x:attribute>
275 <x:attribute name='about'/>
276 <x:attribute name="content">
277 <x:value-of select="translate(substring(@content,8,10),'/','-')"/>
278 <x:text>T</x:text>
279 <x:value-of select="substring(@content,19,8)"/>
280 </x:attribute>
281 </x:element>
282 </x:when>
283 <x:when test="@name='purl'">
284 <x:element name='link' namespace='http://www.w3.org/1999/xhtml'>
285 <x:attribute name='rel'>dc:identifier</x:attribute>
286 <x:attribute name='about'/>
287 <x:attribute name="href">
288 <x:value-of select="@content"/>
289 </x:attribute>
290 </x:element>
291 <x:element name='link' namespace='http://www.w3.org/1999/xhtml'>
292 <x:attribute name='rel'>owl:sameAs</x:attribute>
293 <x:attribute name="href">
294 <x:value-of select="@content"/>
295 </x:attribute>
296 </x:element>
297 </x:when>
298 <x:when test="starts-with(@name,'DC.')">
299 <x:element name='meta' namespace='http://www.w3.org/1999/xhtml'>
300 <x:attribute name='about'/>
301 <x:attribute name="property">dc:<x:value-of select="substring-after(@name, 'DC.')"/>
302 </x:attribute>
303 <x:attribute name="content">
304 <x:value-of select="@content"/>
305 </x:attribute>
306 </x:element>
307 </x:when>
308 </x:choose>
309 </x:template>
310
311 <x:template match="h:div[@class='signature']">
312 <x:copy>
313 <x:apply-templates select="@*"/>
314 <x:choose>
315 <x:when test="h:a/@href">
316 <x:attribute name="rel">dc:creator</x:attribute>
317 <x:attribute name="href">
318 <x:value-of select="h:a/@href"/>
319 </x:attribute>
320 </x:when>
321 <x:otherwise>
322 <x:attribute name="property">dc:creator</x:attribute>
323 <x:attribute name="content">
324 <x:value-of select="h:a/text()"/>
325 </x:attribute>
326 </x:otherwise>
327 </x:choose>
328 <x:apply-templates/>
329 </x:copy>
330 </x:template>
331
332 <x:template match="h:div[@class='abstract']">
333 <x:copy>
334 <x:apply-templates select="@*"/>
335 <x:element name='meta' namespace='http://www.w3.org/1999/xhtml'>
336 <x:attribute name='property'>dcterms:abstract</x:attribute>
337 <x:attribute name='about'/>
338 <x:attribute name="content">
339 <x:apply-templates select="h:p[not(@class)]" mode="text-only"/>
340 </x:attribute>
341 </x:element>
342 <x:apply-templates/>
343 </x:copy>
344 </x:template>
345
346 <x:template match="h:p" mode="text-only">
347 <x:value-of select="normalize-space(.)"/>
348 <x:text> </x:text>
349 </x:template>
350
351 <x:template name="make-tex-command">
352 <x:param name="command"/>
353 <x:param name="content"/>
354 <x:text>\</x:text>
355 <x:value-of select="$command"/>
356 <x:text>{</x:text>
357 <x:value-of select="$content"/>
358 <x:text>}
359 </x:text>
360 </x:template>
361
362 </x:stylesheet>

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26