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