source: trunk/bibtexml2dbk.xsl @ 164

Last change on this file since 164 was 93, checked in by pinsard, 15 years ago

remove most of wiki pages

  • Property svn:keywords set to Id
File size: 7.7 KB
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2<xsl:stylesheet
3version="1.0"
4xmlns:xl="http://www.w3.org/1999/xlink"
5xmlns:html="http://www.w3.org/1999/xhtml"
6xmlns:bibtex="http://bibtexml.sf.net/"
7xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
8
9<!--
10module :
11produce a DocBook 5 from a bibtexml file
12
13update :
14$Id$
15fplod 2008-05-16T14:49:33Z aedon.locean-ipsl.upmc.fr (Darwin)
16add bibtex:book, bibtex:manual and bibtex:misc : biblioset
17fplod 2008-05-16T14:32:48Z aedon.locean-ipsl.upmc.fr (Darwin)
18bug fix on biblioset
19fplod 2008-05-16T10:38:11Z aedon.locean-ipsl.upmc.fr (Darwin)
20add parameter order for firstname/surname order in bibtex file
21fplod 2008-05-15T13:43:34Z aedon.locean-ipsl.upmc.fr (Darwin)
22creation
23see external/bibtex2xml.py (which produce input of the file)
24updated with
25svn co https://bibtexml.svn.sourceforge.net/svnroot/bibtexml/trunk/bibtexml/import/
26note that https://bibtexml.svn.sourceforge.net/svnroot/bibtexml/trunk/bibtexconverter-j/src/net/sourceforge/bibtexml/xslt/bibxml2docbook.xsl produce a Docbook 4file and not DocBook 5 as superbib request.
27-->
28
29<xsl:output
30 method="xml"
31 indent="yes"
32 encoding="utf-8"
33 omit-xml-declaration="no"/>
34
35<xsl:template match="bibtex:file">
36<xsl:element name="bibliography">
37 <xsl:attribute name="version">5.0</xsl:attribute>
38 <xsl:attribute name="xmlns">http://docbook.org/ns/docbook</xsl:attribute>
39 <xsl:attribute name="xml:id"><xsl:value-of select="concat('bib',$project,'ref')"/></xsl:attribute>
40 <xsl:attribute name="xml:lang"><xsl:value-of select="$lang"/></xsl:attribute>
41 <xsl:element name="info">
42  <xsl:element name="date">
43   <xsl:value-of select="$makedate"/>
44  </xsl:element>
45 </xsl:element>
46 <xsl:apply-templates select="bibtex:entry"/>
47</xsl:element>
48<xsl:message>
49www : You should have a look on firstname and surname to overiding on basic parsing
50</xsl:message>
51</xsl:template>
52
53<xsl:template match="bibtex:title">
54<xsl:element name="title">
55 <xsl:value-of select="."/>
56</xsl:element>
57</xsl:template>
58
59<xsl:template match="bibtex:entry">
60<xsl:element name="biblioentry">
61 <xsl:attribute name="xml:id"><xsl:value-of select="@id"/></xsl:attribute>
62<!--++ key as info element-->
63 <xsl:apply-templates select="bibtex:article"/>
64 <xsl:apply-templates select="bibtex:book"/>
65 <xsl:apply-templates select="bibtex:manual"/>
66 <xsl:apply-templates select="bibtex:misc"/>
67</xsl:element>
68</xsl:template>
69
70<xsl:template match="bibtex:year">
71<xsl:element name="pubdate">
72 <xsl:value-of select="."/>
73</xsl:element>
74</xsl:template>
75
76<xsl:template match="bibtex:pages">
77<xsl:element name="pagenums">
78 <xsl:value-of select="."/>
79</xsl:element>
80</xsl:template>
81
82<xsl:template match="bibtex:volume">
83<xsl:element name="volumenum">
84 <xsl:value-of select="."/>
85</xsl:element>
86</xsl:template>
87
88<xsl:template match="bibtex:edition">
89<xsl:element name="edition">
90 <xsl:value-of select="."/>
91</xsl:element>
92</xsl:template>
93
94<xsl:template match="bibtex:journal">
95<xsl:element name="title">
96 <xsl:value-of select="."/>
97</xsl:element>
98</xsl:template>
99
100<xsl:template match="bibtex:article">
101 <xsl:apply-templates select="bibtex:title"/>
102 <xsl:apply-templates select="bibtex:author"/>
103 <xsl:apply-templates select="bibtex:doi"/>
104 <xsl:apply-templates select="bibtex:isbn"/>
105 <xsl:apply-templates select="bibtex:url"/>
106<xsl:element name="biblioset">
107 <xsl:attribute name="relation"><xsl:value-of select="'journal'"/></xsl:attribute>
108 <xsl:apply-templates select="bibtex:journal"/>
109 <xsl:apply-templates select="bibtex:publisher"/>
110 <xsl:apply-templates select="bibtex:organization"/>
111 <xsl:apply-templates select="bibtex:edition"/>
112 <xsl:apply-templates select="bibtex:volume"/>
113 <xsl:apply-templates select="bibtex:pages"/>
114 <xsl:apply-templates select="bibtex:year"/>
115</xsl:element>
116</xsl:template>
117
118<xsl:template match="bibtex:book">
119 <xsl:apply-templates select="bibtex:title"/>
120 <xsl:apply-templates select="bibtex:author"/>
121 <xsl:apply-templates select="bibtex:isbn"/>
122 <xsl:element name="biblioset">
123 <!-- ++ book relation is not yet implented in DocBook processing -->
124  <xsl:attribute name="relation"><xsl:value-of select="'book'"/></xsl:attribute>
125  <xsl:apply-templates select="bibtex:publisher"/>
126  <xsl:apply-templates select="bibtex:edition"/>
127  <xsl:apply-templates select="bibtex:volume"/>
128  <xsl:apply-templates select="bibtex:pages"/>
129  <xsl:apply-templates select="bibtex:year"/>
130 </xsl:element>
131</xsl:template>
132
133<xsl:template match="bibtex:manual">
134 <xsl:apply-templates select="bibtex:title"/>
135 <xsl:apply-templates select="bibtex:author"/>
136 <xsl:element name="biblioset">
137 <!-- ++ manual  relation is not yet implented in DocBook processing -->
138  <xsl:attribute name="relation"><xsl:value-of select="'manual'"/></xsl:attribute>
139  <xsl:apply-templates select="bibtex:year"/>
140  <xsl:apply-templates select="bibtex:publisher"/>
141  <xsl:apply-templates select="bibtex:organization"/>
142 </xsl:element>
143 <xsl:apply-templates select="bibtex:url"/>
144</xsl:template>
145
146<xsl:template match="bibtex:misc">
147 <xsl:apply-templates select="bibtex:title"/>
148 <xsl:apply-templates select="bibtex:author"/>
149 <xsl:element name="biblioset">
150 <!-- can't know precise relation. set to journal-->
151  <xsl:attribute name="relation"><xsl:value-of select="'journal'"/></xsl:attribute>
152  <xsl:apply-templates select="bibtex:year"/>
153 </xsl:element>
154 <xsl:apply-templates select="bibtex:url"/>
155</xsl:template>
156
157
158<xsl:template match="bibtex:publisher|bibtex:organization">
159<xsl:element name="publisher">
160 <xsl:element name="publishername">
161  <xsl:value-of select="."/>
162 </xsl:element>
163</xsl:element>
164</xsl:template>
165
166<xsl:template match="bibtex:isbn">
167<xsl:element name="biblioid">
168 <xsl:attribute name="class"><xsl:value-of select="'isbn'"/></xsl:attribute>
169 <xsl:value-of select="."/>
170</xsl:element>
171</xsl:template>
172
173<xsl:template match="bibtex:doi">
174<xsl:element name="biblioid">
175 <xsl:attribute name="class"><xsl:value-of select="'doi'"/></xsl:attribute>
176 <xsl:value-of select="."/>
177</xsl:element>
178</xsl:template>
179
180<xsl:template match="bibtex:author">
181<xsl:choose>
182 <xsl:when test="count(child::bibtex:person) &gt; 0">
183  <xsl:element name="authorgroup">
184   <xsl:apply-templates select="child::bibtex:person"/>
185  </xsl:element>
186 </xsl:when>
187 <xsl:otherwise>
188  <xsl:element name="authorgroup">
189   <xsl:element name="author">
190    <xsl:element name="personname">
191     <xsl:call-template name="personname" select="."/>
192    </xsl:element>
193   </xsl:element>
194  </xsl:element>
195 </xsl:otherwise>
196</xsl:choose>
197</xsl:template>
198
199<xsl:template match="bibtex:person">
200<xsl:element name="author">
201 <xsl:element name="personname">
202  <xsl:call-template name="personname" select="."/>
203 </xsl:element>
204</xsl:element>
205</xsl:template>
206
207<xsl:template name="personname">
208<!--
209++extremely basic parsing of firstname and surname :
210the first blank is used as a delimiter.
211-->
212<xsl:choose>
213 <xsl:when test="$order = 'fs'">
214  <xsl:element name="firstname">
215   <xsl:value-of select="substring-before(.,' ')"/>
216  </xsl:element>
217  <xsl:element name="surname">
218   <xsl:value-of select="substring-after(.,' ')"/>
219  </xsl:element>
220 </xsl:when>
221 <xsl:when test="$order = 'sf'">
222  <xsl:element name="firstname">
223   <xsl:value-of select="substring-after(.,' ')"/>
224  </xsl:element>
225  <xsl:element name="surname">
226   <xsl:value-of select="substring-before(.,' ')"/>
227  </xsl:element>
228 </xsl:when>
229 <xsl:otherwise>
230  <xsl:message terminate="yes">
231  eee : unknown order value : <xsl:value-of select="$order"/>
232  </xsl:message>
233 </xsl:otherwise>
234</xsl:choose>
235</xsl:template>
236
237<xsl:template match="bibtex:url">
238<xsl:element name="biblioid">
239 <xsl:attribute name="class"><xsl:value-of select="'uri'"/></xsl:attribute>
240 <xsl:value-of select="."/>
241</xsl:element>
242</xsl:template>
243
244<xsl:template match="bibtex:key">
245<!--++ keywords-->
246<xsl:element name="bibliomisc">
247 <xsl:attribute name="role"><xsl:value-of select="'key'"/></xsl:attribute>
248 <xsl:value-of select="."/>
249</xsl:element>
250</xsl:template>
251
252</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.