/[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 714 - (show annotations)
Wed Aug 6 20:02:09 2008 UTC (12 years, 3 months ago) by norman.x.gray
File size: 10631 byte(s)
Change the way that vocabulary.html is generated from vocabulary.xml,
  after discovering some weirdness with the rendering of the
  previously generated file in some browsers -- some odd interaction
  between XHTML content and links and maybe the text/html MIME type, I
  don't know.
I now generate the XHTML and then convert it to HTML using an identity
  transform.

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="http://www.w3.org/1999/xhtml"
7 xmlns:dc="http://purl.org/dc/elements/1.1/"
8 xmlns:dcterms="http://purl.org/dc/terms/">
9
10 <x:output method="xml"
11 encoding="UTF-8"
12 version="1.0"/>
13
14 <!-- We include support for RDFa in the following, via: the output doctype,
15 the 'profile' attribute in the head element, and the various 'property'
16 attributes in the text.
17 See <http://www.w3.org/TR/2008/WD-rdfa-syntax-20080221/#docconf>.
18 We also add a GRDDL transformation which independently specifies
19 the RDFa transformation. -->
20
21 <x:param name="target"/>
22
23 <x:param name="document-id">document-id</x:param>
24
25 <!-- default identity transformation -->
26 <x:template match="node()|@*">
27 <x:copy>
28 <x:apply-templates select="node()|@*"/>
29 </x:copy>
30 </x:template>
31
32 <!-- process root node -->
33 <x:template match="/">
34 <x:choose>
35 <x:when test="$target='aux'">
36 <x:apply-templates select="//processing-instruction('bibliography')"
37 mode="extract-aux"/>
38 </x:when>
39 <x:when test="$target">
40 <x:message terminate="yes">Unrecognised target <x:value-of select="$target"/>
41 </x:message>
42 </x:when>
43 <x:otherwise>
44 <x:apply-templates/>
45 </x:otherwise>
46 </x:choose>
47 </x:template>
48
49 <!-- Add the GRDDL transformation magic attribute to the HTML element -->
50 <x:template match="h:html" xmlns:grddl="http://www.w3.org/2003/g/data-view#">
51 <html grddl:transformation='http://ns.inria.fr/grddl/rdfa/2007/05/25/RDFa2RDFXML.xsl'>
52 <x:apply-templates/>
53 </html>
54 </x:template>
55
56 <x:template match="h:head">
57 <head profile='http://www.w3.org/1999/xhtml/vocab'>
58 <x:apply-templates select="@*"/>
59 <x:copy-of select="namespace::*[.='http://purl.org/dc/elements/1.1/']"/>
60 <x:choose>
61 <x:when test="h:link[@rel='stylesheet']">
62 <x:comment>Using stylesheet from source file</x:comment>
63 <x:apply-templates select="h:link[@rel='stylesheet']"/>
64 </x:when>
65 <x:otherwise>
66 <link rel="stylesheet" type="text/css" href="/style/base.css"/>
67 </x:otherwise>
68 </x:choose>
69 <x:apply-templates select="h:title|h:meta|h:style"/>
70 </head>
71 </x:template>
72
73
74 <x:template match="h:div[@class='section' or @class='section-nonum']">
75 <x:variable name='id'>
76 <x:call-template name='make-section-id'/>
77 </x:variable>
78 <x:variable name="level">
79 <x:choose>
80 <x:when test="ancestor::h:div[@class='section']/ancestor::h:div[@class='section']">h4</x:when>
81 <x:when test="ancestor::h:div[@class='section']">h3</x:when>
82 <x:otherwise>h2</x:otherwise>
83 </x:choose>
84 </x:variable>
85 <x:element name='{$level}'>
86 <a name='{$id}'><x:apply-templates select='.' mode='make-section-name'/></a>
87 </x:element>
88 <x:apply-templates/>
89 </x:template>
90 <!--
91 <x:template match="h:div[@class='section' or @class='section-nonum']">
92 <x:variable name="id">
93 <x:call-template name="make-section-id"/>
94 </x:variable>
95 <x:variable name="level">
96 <x:choose>
97 <x:when test="ancestor::h:div[@class='section']/ancestor::h:div[@class='section']">h4</x:when>
98 <x:when test="ancestor::h:div[@class='section']">h3</x:when>
99 <x:otherwise>h2</x:otherwise>
100 </x:choose>
101 </x:variable>
102 <x:element name="{$level}" namespace='http://www.w3.org/1999/xhtml'>
103 <x:if test="@id">
104 <x:attribute name='class'>hlink</x:attribute>
105 </x:if>
106 <x:apply-templates select="." mode="make-section-name"/>
107 <x:element name='a' namespace='http://www.w3.org/1999/xhtml'>
108 <x:attribute name='name'><x:value-of select='$id'/></x:attribute>
109 <x:if test="@id">
110 <x:attribute name='href'>#<x:value-of select='$id'/></x:attribute>
111 <x:text> [link here]</x:text>
112 </x:if>
113 </x:element>
114 </x:element>
115 <x:apply-templates/>
116 </x:template>
117 -->
118
119 <x:template match="h:p[@class='title']"/>
120
121 <x:template match="h:div[@class='appendices']">
122 <h2>Appendices</h2>
123 <x:apply-templates/>
124 </x:template>
125
126 <x:template match="h:div" mode="make-toc">
127 <x:variable name="id">
128 <x:call-template name="make-section-id"/>
129 </x:variable>
130 <li>
131 <a href='#{$id}'>
132 <x:apply-templates select='.' mode='make-section-name'/>
133 </a>
134 <x:if test="h:div[@class='section' or @class='section-nonum']">
135 <ul>
136 <x:apply-templates select="h:div[@class='section' or @class='section-nonum']" mode="make-toc"/>
137 </ul>
138 </x:if>
139 </li>
140 </x:template>
141
142 <x:template match="processing-instruction('toc')">
143 <div id='toc' class='toc'>
144 <ul>
145 <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"/>
146 </ul>
147 </div>
148 </x:template>
149
150 <x:template name="make-section-id">
151 <x:choose>
152 <x:when test="@id">
153 <x:value-of select="@id"/>
154 </x:when>
155 <x:otherwise>
156 <x:value-of select="generate-id()"/>
157 </x:otherwise>
158 </x:choose>
159 </x:template>
160
161 <x:template match="h:div" mode="make-section-name">
162 <x:choose>
163 <x:when test="ancestor-or-self::h:div[@class='section-nonum']"/>
164 <x:when test="ancestor::h:div[@class='appendices']">
165 <x:number count="h:div[@class='section']" level="multiple" format="A.1."/>
166 <x:text> </x:text>
167 </x:when>
168 <x:otherwise>
169 <x:number count="h:div[@class='section']" level="multiple" format="1.1."/>
170 <x:text> </x:text>
171 </x:otherwise>
172 </x:choose>
173 <x:apply-templates select="h:p[@class='title']/text()"/>
174 </x:template>
175
176 <x:template match="processing-instruction('bibliography')">
177 <x:copy-of select="document(concat(substring-before($document-id, '.xml'),'.bbl'))"/>
178 </x:template>
179
180 <x:template match="h:span[@class='cite']">
181 <em>[<a href='#ref:{text()}'><x:value-of select='.'/></a>]</em>
182 </x:template>
183
184 <x:template match="h:span[@class='url']">
185 <a href='{text()}'>
186 <span class='url'><x:value-of select='.'/></span>
187 </a>
188 </x:template>
189
190 <x:template match="processing-instruction('bibliography')" mode="extract-aux">
191 <x:text>\relax
192 </x:text>
193 <x:apply-templates select="//h:span[@class='cite']" mode="extract-aux"/>
194 <x:if test="string-length(.) &gt; 0">
195 <x:call-template name="make-tex-command">
196 <x:with-param name="command">bibdata</x:with-param>
197 <x:with-param name="content">
198 <x:value-of select="normalize-space(.)"/>
199 </x:with-param>
200 </x:call-template>
201 </x:if>
202 </x:template>
203
204 <x:template match="h:span[@class='cite']" mode="extract-aux">
205 <x:call-template name="make-tex-command">
206 <x:with-param name="command">citation</x:with-param>
207 <x:with-param name="content">
208 <x:copy-of select="."/>
209 </x:with-param>
210 </x:call-template>
211 </x:template>
212
213 <x:key name="xrefs" match="h:div" use="@id"/>
214
215 <x:template match="h:span[@class='xref']">
216 <x:variable name="id" select="."/>
217 <a href='#{$id}'>
218 <x:apply-templates select="key('xrefs',$id)" mode="make-section-name"/>
219 </a>
220 </x:template>
221
222 <x:template match="h:span[@class='rcsinfo']">
223 <x:value-of select="substring-before(substring-after(.,': '),' $')"/>
224 </x:template>
225
226 <x:template match="h:h1">
227 <h1 property='dc:title'>
228 <x:apply-templates select="@*"/>
229 <x:apply-templates/>
230 </h1>
231 </x:template>
232
233 <x:template xmlns:owl="http://www.w3.org/2002/07/owl#" match="h:meta">
234 <x:choose>
235 <x:when test="@name='DC.rights'">
236 <link about='' rel='{@name}' href='{@content}'/>
237 </x:when>
238 <x:when test="@name='rcsdate'">
239 <meta about='' property='dcterms:modified'>
240 <x:attribute name='content'>
241 <x:value-of select="translate(substring(@content,8,10),'/','-')"/>
242 <x:text>T</x:text>
243 <x:value-of select="substring(@content,19,8)"/>
244 </x:attribute>
245 </meta>
246 </x:when>
247 <x:when test="@name='purl'">
248 <link about='' rel='dc:identifier' href='{@content}'/>
249 <link about='' rel='owl:sameAs' href='{@content}'/>
250 </x:when>
251 <x:when test="starts-with(@name,'DC.')">
252 <meta about='' content='{@content}'>
253 <x:attribute name="property">dc:<x:value-of select="substring-after(@name, 'DC.')"/>
254 </x:attribute>
255 </meta>
256 </x:when>
257 <x:when test='@property and @content'>
258 <!-- it's a well-formed RDFa meta element, so copy it over -->
259 <x:copy-of select='.'/>
260 </x:when>
261 </x:choose>
262 </x:template>
263
264 <x:template match="h:div[@class='signature']">
265 <x:copy>
266 <x:apply-templates select="@*"/>
267 <x:choose>
268 <x:when test="h:a/@href">
269 <x:attribute name="rel">dc:creator</x:attribute>
270 <x:attribute name="href">
271 <x:value-of select="h:a/@href"/>
272 </x:attribute>
273 </x:when>
274 <x:otherwise>
275 <x:attribute name="property">dc:creator</x:attribute>
276 <x:attribute name="content">
277 <x:value-of select="h:a/text()"/>
278 </x:attribute>
279 </x:otherwise>
280 </x:choose>
281 <x:apply-templates/>
282 </x:copy>
283 </x:template>
284
285 <x:template match="h:div[@class='abstract']">
286 <x:copy>
287 <x:apply-templates select="@*"/>
288 <x:element name='meta' namespace='http://www.w3.org/1999/xhtml'>
289 <x:attribute name='property'>dcterms:abstract</x:attribute>
290 <x:attribute name='about'/>
291 <x:attribute name="content">
292 <x:apply-templates select="h:p[not(@class)]" mode="text-only"/>
293 </x:attribute>
294 </x:element>
295 <x:apply-templates/>
296 </x:copy>
297 </x:template>
298
299 <x:template match="h:q">
300 <x:text></x:text>
301 <x:apply-templates/>
302 <x:text></x:text>
303 </x:template>
304
305 <x:template match="h:p" mode="text-only">
306 <x:value-of select="normalize-space(.)"/>
307 <x:text> </x:text>
308 </x:template>
309
310 <x:template name="make-tex-command">
311 <x:param name="command"/>
312 <x:param name="content"/>
313 <x:text>\</x:text>
314 <x:value-of select="$command"/>
315 <x:text>{</x:text>
316 <x:value-of select="$content"/>
317 <x:text>}
318 </x:text>
319 </x:template>
320
321 </x:stylesheet>

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