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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Mon Dec 3 22:17:21 2007 UTC (13 years, 6 months ago) by norman.x.gray
File size: 11578 byte(s)
Create initial structure, and copy draft note-so-far from Explicator repository.

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

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