Debian Codegraph @

xsl/verbatim.xsl

raw
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
3
4 <!--############################################################################
5 XSLT Stylesheet DocBook -> LaTeX
6 ############################################################################ -->
7
8 <!-- Literal parameters -->
9 <xsl:param name="literal.width.ignore">0</xsl:param>
10 <xsl:param name="literal.layout.options"/>
11 <xsl:param name="literal.lines.showall">1</xsl:param>
12 <xsl:param name="literal.role"/>
13 <xsl:param name="literal.class">monospaced</xsl:param>
14 <xsl:param name="literal.extensions"/>
15 <xsl:param name="linenumbering.scope"/>
16 <xsl:param name="linenumbering.default"/>
17 <xsl:param name="linenumbering.everyNth"/>
18 <!-- Use scalable dblatex listing if the feature is required -->
19 <xsl:param name="literal.environment">
20 <xsl:choose>
21 <xsl:when test="contains($literal.extensions,'scale')">
22 <xsl:text>lstcode</xsl:text>
23 </xsl:when>
24 <xsl:otherwise>
25 <xsl:text>lstlisting</xsl:text>
26 </xsl:otherwise>
27 </xsl:choose>
28 </xsl:param>
29
30
31 <xsl:template name="verbatim.setup">
32 <!-- dblatex requires that a listing environment starts with 'lst' -->
33 <xsl:if test="substring($literal.environment,1,3) != 'lst'">
34 <xsl:message terminate="yes">
35 <xsl:text>Error: </xsl:text>
36 <xsl:value-of select="$literal.environment"/>
37 <xsl:text>: a listing environment must start with 'lst'</xsl:text>
38 </xsl:message>
39 </xsl:if>
40 <xsl:apply-templates select="//screen|//programlisting"
41 mode="save.verbatim.preamble"/>
42 </xsl:template>
43
44 <xsl:template name="verbatim.setup2">
45 <xsl:text>\lstsetup&#10;</xsl:text>
46 </xsl:template>
47
48
49 <xsl:template match="address">
50 <xsl:call-template name="output.verbatim"/>
51 </xsl:template>
52
53 <xsl:template match="text()" mode="save.verbatim"/>
54
55 <xsl:template match="address"
56 mode="save.verbatim">
57 <xsl:call-template name="save.verbatim"/>
58 </xsl:template>
59
60 <xsl:template name="save.verbatim">
61 <xsl:param name="content">
62 <xsl:apply-templates mode="latex.verbatim"/>
63 </xsl:param>
64 <xsl:text>&#10;\begin{SaveVerbatim}{</xsl:text>
65 <xsl:value-of select="generate-id()"/>
66 <xsl:text>}&#10;</xsl:text>
67 <xsl:value-of select="$content"/>
68 <xsl:text>&#10;\end{SaveVerbatim}&#10;</xsl:text>
69 </xsl:template>
70
71 <xsl:template name="output.verbatim">
72 <xsl:param name="content">
73 <xsl:apply-templates mode="latex.verbatim"/>
74 </xsl:param>
75 <!-- In tables just use the data previously saved -->
76 <xsl:choose>
77 <xsl:when test="ancestor::entry|
78 ancestor::legalnotice">
79 <xsl:text>\UseVerbatim{</xsl:text>
80 <xsl:value-of select="generate-id(.)"/>
81 <xsl:text>}</xsl:text>
82 </xsl:when>
83 <xsl:otherwise>
84 <xsl:text>&#10;\begin{verbatim}</xsl:text>
85 <xsl:value-of select="$content"/>
86 <xsl:text>\end{verbatim}&#10;</xsl:text>
87 </xsl:otherwise>
88 </xsl:choose>
89 </xsl:template>
90
91 <!-- Special cases where nothing to output in verbatim mode -->
92 <xsl:template match="alt" mode="latex.verbatim"/>
93
94 <!-- Returns the filename from @fileref or @entityref attribute -->
95 <xsl:template match="*" mode="filename.get">
96 <xsl:choose>
97 <xsl:when test="@entityref">
98 <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
99 </xsl:when>
100 <xsl:otherwise>
101 <xsl:value-of select="@fileref"/>
102 </xsl:otherwise>
103 </xsl:choose>
104 </xsl:template>
105
106 <!-- ==================================================================== -->
107
108 <!-- Template that must be called by elements that want to be escaped in a
109 programlisting environment. It escapes the tex sequence, *but* prints
110 out the sequence only if probing is not required (i.e. = 0).
111
112 Probing is used by a parent that wants to know if it contains some
113 element that needs some tex escaping.
114 -->
115
116 <xsl:template name="verbatim.embed">
117 <xsl:param name="co-tagin" select="'&lt;'"/>
118 <xsl:param name="rnode" select="/"/>
119 <xsl:param name="probe" select="0"/>
120 <xsl:param name="content"/>
121
122 <xsl:value-of select="concat($co-tagin, 't&gt;')"/>
123 <xsl:if test="$probe = 0">
124 <xsl:choose>
125 <xsl:when test="$content != ''">
126 <xsl:value-of select="$content"/>
127 </xsl:when>
128 <xsl:otherwise>
129 <xsl:apply-templates select="."/>
130 </xsl:otherwise>
131 </xsl:choose>
132 </xsl:if>
133 <xsl:value-of select="'&lt;/t&gt;'"/>
134 </xsl:template>
135
136 <!-- Template to format (bold, italic) the calling element. The format is
137 specified by the <style> that drives the corresponding delimiter
138 sequence. Styles can be nested, so apply the same template mode to
139 children.
140 -->
141
142 <xsl:template name="verbatim.format">
143 <xsl:param name="co-tagin" select="'&lt;'"/>
144 <xsl:param name="rnode" select="/"/>
145 <xsl:param name="probe" select="0"/>
146 <xsl:param name="style" select="'b'"/>
147 <xsl:param name="content"/>
148
149 <xsl:value-of select="concat($co-tagin, $style, '&gt;')"/>
150 <xsl:if test="$probe = 0">
151 <xsl:choose>
152 <xsl:when test="$content != ''">
153 <xsl:value-of select="$content"/>
154 </xsl:when>
155 <xsl:otherwise>
156 <xsl:apply-templates mode="latex.programlisting">
157 <xsl:with-param name="co-tagin" select="$co-tagin"/>
158 <xsl:with-param name="rnode" select="$rnode"/>
159 <xsl:with-param name="probe" select="$probe"/>
160 </xsl:apply-templates>
161 </xsl:otherwise>
162 </xsl:choose>
163 </xsl:if>
164 <xsl:value-of select="concat('&lt;/', $style, '&gt;')"/>
165 </xsl:template>
166
167 <!-- A latex Processing-Instruction in verbatim is meaningfull, so
168 process it.
169 -->
170
171 <xsl:template match="processing-instruction('latex')"
172 mode="latex.programlisting">
173 <xsl:param name="co-tagin" select="'&lt;'"/>
174 <xsl:param name="rnode" select="/"/>
175 <xsl:param name="probe" select="0"/>
176
177 <xsl:value-of select="concat($co-tagin, 't', '&gt;')"/>
178 <xsl:value-of select="."/>
179 <xsl:value-of select="concat('&lt;/', 't', '&gt;')"/>
180 </xsl:template>
181
182 <!-- ==================================================================== -->
183
184 <!-- By default an element in a programlisting environment just prints out its
185 text() adapted to this environment, and apply to its children the same
186 template. -->
187
188 <xsl:template match="*" mode="latex.programlisting">
189 <xsl:param name="co-tagin" select="'&lt;'"/>
190 <xsl:param name="rnode" select="/"/>
191 <xsl:param name="probe" select="0"/>
192
193 <xsl:if test="$output.quietly = 0">
194 <xsl:message>
195 <xsl:value-of select="local-name(.)"/>
196 <xsl:text>: default template used in programlisting or screen</xsl:text>
197 </xsl:message>
198 </xsl:if>
199
200 <xsl:apply-templates mode="latex.programlisting">
201 <xsl:with-param name="co-tagin" select="$co-tagin"/>
202 <xsl:with-param name="rnode" select="$rnode"/>
203 <xsl:with-param name="probe" select="$probe"/>
204 </xsl:apply-templates>
205 </xsl:template>
206
207
208 <!-- ==================================================================== -->
209
210 <!-- The following templates now works only with the listings package -->
211
212 <!-- The listing content is internal to the element, and is not a reference
213 to an external file -->
214
215 <xsl:template match="programlisting|screen|literallayout" mode="internal">
216 <xsl:param name="opt"/>
217 <xsl:param name="co-tagin"/>
218 <xsl:param name="rnode" select="/"/>
219 <xsl:param name="env" select="'lstlisting'"/>
220
221
222 <xsl:text>&#10;\begin{</xsl:text>
223 <xsl:value-of select="$env"/>
224 <xsl:text>}</xsl:text>
225 <xsl:if test="$opt!=''">
226 <xsl:text>[</xsl:text>
227 <xsl:value-of select="$opt"/>
228 <xsl:text>]</xsl:text>
229 </xsl:if>
230 <!-- some text just after the open tag must be put on a new line -->
231 <xsl:if test="not(contains(.,'&#10;')) or
232 string-length(normalize-space(
233 substring-before(.,'&#10;')))&gt;0">
234 <xsl:text>&#10;</xsl:text>
235 </xsl:if>
236 <xsl:apply-templates mode="latex.programlisting">
237 <xsl:with-param name="co-tagin" select="$co-tagin"/>
238 <xsl:with-param name="rnode" select="$rnode"/>
239 </xsl:apply-templates>
240 <!-- ensure to have the end on a separate line -->
241 <xsl:if test="substring(.,string-length(.))!='&#10;' and
242 substring(translate(.,' &#09;',''),
243 string-length(translate(.,' &#09;','')))!='&#10;'">
244 <xsl:text>&#10;</xsl:text>
245 </xsl:if>
246 <xsl:text>\end{</xsl:text>
247 <xsl:value-of select="$env"/>
248 <xsl:text>}&#10;</xsl:text>
249 </xsl:template>
250
251 <!-- ==================================================================== -->
252
253 <xsl:template name="linenumbering">
254 <xsl:choose>
255 <xsl:when test="@linenumbering='numbered'">1</xsl:when>
256 <xsl:when test="@linenumbering and @linenumbering!='numbered'">0</xsl:when>
257 <xsl:when test="$linenumbering.default='numbered' and
258 (contains(concat(' ',$linenumbering.scope,' '),
259 concat(' ',local-name(.),' ')))">1</xsl:when>
260 <xsl:otherwise>0</xsl:otherwise>
261 </xsl:choose>
262 </xsl:template>
263
264 <xsl:template match="programlisting|screen|literallayout">
265 <xsl:param name="rnode" select="/"/>
266
267 <!-- formula to compute the listing width -->
268 <xsl:variable name="width">
269 <xsl:if test="$literal.width.ignore='0' and
270 @width and string(number(@width))!='NaN'">
271 <xsl:text>\setlength{\lstwidth}{</xsl:text>
272 <xsl:value-of select="@width"/>
273 <xsl:text>\lstcharwidth+2\lstframesep}</xsl:text>
274 </xsl:if>
275 </xsl:variable>
276
277 <!-- is there some elements needing escaping? -->
278 <xsl:variable name="escaped">
279 <xsl:apply-templates mode="latex.programlisting">
280 <xsl:with-param name="probe" select="1"/>
281 </xsl:apply-templates>
282 </xsl:variable>
283
284 <!-- get the listing escape sequence if needed -->
285 <xsl:variable name="co-tagin">
286 <xsl:if test="descendant::co or $escaped != ''">
287 <xsl:call-template name="co-tagin-gen"/>
288 </xsl:if>
289 </xsl:variable>
290
291 <xsl:variable name="linenumbered">
292 <xsl:call-template name="linenumbering"/>
293 </xsl:variable>
294
295 <xsl:variable name="role">
296 <xsl:choose>
297 <xsl:when test="@role">
298 <xsl:value-of select="@role"/>
299 </xsl:when>
300 <xsl:otherwise>
301 <xsl:value-of select="$literal.role"/>
302 </xsl:otherwise>
303 </xsl:choose>
304 </xsl:variable>
305
306 <xsl:variable name="opt">
307 <!-- skip empty endlines -->
308 <xsl:if test="$literal.lines.showall='0'">
309 <xsl:text>showlines=false,</xsl:text>
310 </xsl:if>
311 <!-- Remove wrap mode if required -->
312 <xsl:if test="$role='overflow'">
313 <xsl:text>breaklines=false,</xsl:text>
314 </xsl:if>
315 <!-- The scaling feature is not available with standard listings -->
316 <xsl:if test="contains($literal.extensions, 'scale')">
317 <xsl:choose>
318 <xsl:when test="$role='scale' or
319 ($role='' and $literal.extensions='scale.by.width' and $width!='')">
320 <xsl:text>scale=true,</xsl:text>
321 <!-- don't wrap to scale to the longest line if no width specified -->
322 <xsl:if test="$width=''">
323 <xsl:text>breaklines=false,</xsl:text>
324 </xsl:if>
325 </xsl:when>
326 <xsl:otherwise>
327 <xsl:text>scale=false,</xsl:text>
328 </xsl:otherwise>
329 </xsl:choose>
330 </xsl:if>
331 <!-- language option is only for programlisting -->
332 <xsl:if test="@language">
333 <xsl:text>language={</xsl:text>
334 <xsl:value-of select="@language"/>
335 <xsl:text>},</xsl:text>
336 </xsl:if>
337 <!-- listing width -->
338 <xsl:if test="$width!=''">
339 <xsl:text>linewidth=\lstwidth,</xsl:text>
340 </xsl:if>
341 <!-- print line numbers -->
342 <xsl:if test="$linenumbered=1">
343 <xsl:text>numbers=left,</xsl:text>
344 <xsl:if test="number($linenumbering.everyNth) &gt; 1">
345 <xsl:text>stepnumber=</xsl:text>
346 <xsl:value-of select="number($linenumbering.everyNth)"/>
347 <xsl:text>,</xsl:text>
348 </xsl:if>
349 </xsl:if>
350 <!-- find the fist line number to print -->
351 <xsl:choose>
352 <xsl:when test="@startinglinenumber">
353 <xsl:text>firstnumber=</xsl:text>
354 <xsl:value-of select="@startinglinenumber"/>
355 <xsl:text>,</xsl:text>
356 </xsl:when>
357 <xsl:when test="@continuation and (@continuation='continues')">
358 <!-- ask for continuation -->
359 <xsl:text>firstnumber=last</xsl:text>
360 <xsl:text>,</xsl:text>
361 </xsl:when>
362 <xsl:otherwise>
363 <!-- explicit restart numbering -->
364 <xsl:text>firstnumber=1</xsl:text>
365 <xsl:text>,</xsl:text>
366 </xsl:otherwise>
367 </xsl:choose>
368 <!-- In literallayout no specific background, nor monospaced font -->
369 <xsl:if test="self::literallayout">
370 <xsl:text>backgroundcolor={},</xsl:text>
371 <xsl:choose>
372 <xsl:when test="@class='monospaced' or
373 $literal.class='monospaced'">
374 <xsl:text>basicstyle=\ttfamily,</xsl:text>
375 </xsl:when>
376 <xsl:otherwise>
377 <xsl:text>basicstyle=\normalfont,flexiblecolumns,</xsl:text>
378 </xsl:otherwise>
379 </xsl:choose>
380 </xsl:if>
381 <!-- TeX/verb delimiters if tex or formatting is embedded (like <co>s) -->
382 <xsl:if test="$co-tagin!=''">
383 <xsl:call-template name="listing-delim">
384 <xsl:with-param name="tagin" select="$co-tagin"/>
385 </xsl:call-template>
386 </xsl:if>
387 </xsl:variable>
388
389 <!-- put the listing with formula here -->
390 <xsl:if test="$width!=''">
391 <xsl:text>&#10;</xsl:text>
392 <xsl:value-of select="$width"/>
393 </xsl:if>
394 <xsl:choose>
395 <xsl:when test="descendant::imagedata[@format='linespecific']|
396 descendant::inlinegraphic[@format='linespecific']|
397 descendant::textdata">
398 <!-- the listing content is in an external file -->
399 <xsl:text>&#10;\lstinputlisting</xsl:text>
400 <xsl:if test="$opt!=''">
401 <xsl:text>[</xsl:text>
402 <xsl:value-of select="$opt"/>
403 <xsl:text>]</xsl:text>
404 </xsl:if>
405 <xsl:text>{</xsl:text>
406 <xsl:apply-templates
407 select="descendant::imagedata|descendant::inlinegraphic|
408 descendant::textdata"
409 mode="filename.get"/>
410 <xsl:text>}&#10;</xsl:text>
411 </xsl:when>
412 <xsl:otherwise>
413 <!-- the listing content is internal -->
414 <xsl:apply-templates select="." mode="internal">
415 <xsl:with-param name="rnode" select="$rnode"/>
416 <xsl:with-param name="co-tagin" select="$co-tagin"/>
417 <xsl:with-param name="opt" select="$opt"/>
418 <xsl:with-param name="env" select="$literal.environment"/>
419 </xsl:apply-templates>
420 </xsl:otherwise>
421 </xsl:choose>
422 </xsl:template>
423
424 <!-- ==================================================================== -->
425
426 <!-- Defines the style delimiters to use, and the tex sequence delimiters -->
427
428 <xsl:template name="listing-delim">
429 <xsl:param name="tagin" select="'&lt;'"/>
430 <xsl:variable name="tex" select="concat($tagin, 't&gt;')"/>
431 <xsl:variable name="bf" select="concat($tagin, 'b&gt;')"/>
432 <xsl:variable name="it" select="concat($tagin, 'i&gt;')"/>
433
434 <xsl:text>escapeinside={</xsl:text>
435 <xsl:value-of select="$tex"/>
436 <xsl:text>}{&lt;/t&gt;}</xsl:text>
437 <xsl:text>,</xsl:text>
438 <xsl:text>moredelim={**[is][\bfseries]{</xsl:text>
439 <xsl:value-of select="$bf"/>
440 <xsl:text>}{&lt;/b&gt;}},</xsl:text>
441 <xsl:text>moredelim={**[is][\itshape]{</xsl:text>
442 <xsl:value-of select="$it"/>
443 <xsl:text>}{&lt;/i&gt;}},</xsl:text>
444 </xsl:template>
445
446 <!-- ==================================================================== -->
447
448 <!-- Global listing saving, for listings in footnotes, since we never know
449 in which context the footnotes are used. A check is done to not cover
450 the other saving points in tables. -->
451
452 <xsl:template match="programlisting|screen|literallayout"
453 mode="save.verbatim.preamble">
454 <xsl:if test="not(ancestor::table or ancestor::informaltable) and
455 ancestor::footnote">
456 <xsl:apply-templates select="." mode="save.verbatim"/>
457 </xsl:if>
458 </xsl:template>
459
460
461 <!-- Listings does not work in tables, even for external files. So, we
462 use the fancyvrb verbatim coupled to listings for the rendering stuff.
463 This mode assumes that all the verbatim data is in an external
464 file. Using the save/use commands would work except for linenumbering
465 stuff. -->
466
467 <xsl:template match="programlisting|screen|literallayout"
468 mode="save.verbatim">
469 <xsl:if test="not(descendant::imagedata[@format='linespecific']|
470 descendant::inlinegraphic[@format='linespecific']|
471 descendant::textdata)">
472 <xsl:variable name="str1" select="."/>
473 <xsl:variable name="str">
474 <xsl:apply-templates mode="latex.programlisting"/>
475 </xsl:variable>
476
477 <xsl:text>\begin{VerbatimOut}{tmplst-</xsl:text>
478 <xsl:value-of select="generate-id()"/>
479 <xsl:text>}</xsl:text>
480 <!-- some text just after the open tag must be put on a new line -->
481 <xsl:if test="not(contains($str1,'&#10;')) or
482 string-length(
483 normalize-space(substring-before($str1,'&#10;')))&gt;0">
484 <xsl:text>&#10;</xsl:text>
485 </xsl:if>
486 <xsl:value-of select="$str"/>
487 <!-- put a \n only if needed -->
488 <xsl:if test="substring($str1,string-length($str1))!='&#10;' and
489 substring(translate($str1,' &#09;',''),
490 string-length(translate($str1,' &#09;','')))!='&#10;'">
491 <xsl:text>&#10;</xsl:text>
492 </xsl:if>
493 <xsl:text>\end{VerbatimOut}&#10;</xsl:text>
494 </xsl:if>
495 </xsl:template>
496
497
498 <!-- Special case for literal blocks in tables or foonotes -->
499 <xsl:template match="*[self::entry or
500 self::entrytbl or
501 self::footnote]//
502 *[self::programlisting or
503 self::screen or
504 self::literallayout]">
505
506 <xsl:variable name="lsopt">
507 <!-- language option is only for programlisting -->
508 <xsl:if test="@language">
509 <xsl:text>language=</xsl:text>
510 <xsl:value-of select="@language"/>
511 <xsl:text>,</xsl:text>
512 </xsl:if>
513 </xsl:variable>
514
515 <xsl:variable name="linenumbered">
516 <xsl:call-template name="linenumbering"/>
517 </xsl:variable>
518
519 <xsl:variable name="fvopt">
520 <!-- print line numbers -->
521 <xsl:if test="$linenumbered=1">
522 <xsl:text>numbers=left,</xsl:text>
523 <xsl:if test="number($linenumbering.everyNth) &gt; 1">
524 <xsl:text>stepnumber=</xsl:text>
525 <xsl:value-of select="number($linenumbering.everyNth)"/>
526 <xsl:text>,</xsl:text>
527 </xsl:if>
528 <!-- find the fist line number to print -->
529 <xsl:choose>
530 <xsl:when test="@startinglinenumber">
531 <xsl:text>firstnumber=</xsl:text>
532 <xsl:value-of select="@startinglinenumber"/>
533 <xsl:text>,</xsl:text>
534 </xsl:when>
535 <xsl:when test="@continuation and (@continuation='continues')">
536 <!-- ask for continuation -->
537 <xsl:text>firstnumber=last</xsl:text>
538 <xsl:text>,</xsl:text>
539 </xsl:when>
540 <xsl:otherwise>
541 <!-- explicit restart numbering -->
542 <xsl:text>firstnumber=1</xsl:text>
543 <xsl:text>,</xsl:text>
544 </xsl:otherwise>
545 </xsl:choose>
546 </xsl:if>
547 <!-- In literallayout no specific background, nor monospaced font -->
548 <xsl:if test="self::literallayout">
549 <xsl:choose>
550 <xsl:when test="@class='monospaced' or
551 $literal.class='monospaced'">
552 <xsl:text>fontfamily=tt,</xsl:text>
553 </xsl:when>
554 <!-- FIXME: don't know how to force to use normal text font -->
555 </xsl:choose>
556 </xsl:if>
557
558 <!-- TODO: TeX delimiters if <co>s are embedded. Use commandchars -->
559 </xsl:variable>
560
561 <xsl:text>\begin{fvlisting}</xsl:text>
562 <xsl:if test="$lsopt!=''">
563 <xsl:text>[</xsl:text>
564 <xsl:value-of select="$lsopt"/>
565 <xsl:text>]</xsl:text>
566 </xsl:if>
567 <xsl:text>&#10;</xsl:text>
568
569 <xsl:text>\VerbatimInput</xsl:text>
570 <xsl:if test="$fvopt!=''">
571 <xsl:text>[</xsl:text>
572 <xsl:value-of select="$fvopt"/>
573 <xsl:text>]</xsl:text>
574 </xsl:if>
575
576 <xsl:text>{</xsl:text>
577 <xsl:choose>
578 <xsl:when test="descendant::imagedata[@format='linespecific']|
579 descendant::inlinegraphic[@format='linespecific']|
580 descendant::textdata">
581 <!-- the listing content is in a (real) external file -->
582 <xsl:apply-templates
583 select="descendant::imagedata|descendant::inlinegraphic|
584 descendant::textdata"
585 mode="filename.abs.get"/>
586 </xsl:when>
587 <xsl:otherwise>
588 <!-- the listing is outputed in a temporary file -->
589 <xsl:text>tmplst-</xsl:text>
590 <xsl:value-of select="generate-id(.)"/>
591 </xsl:otherwise>
592 </xsl:choose>
593 <xsl:text>}&#10;</xsl:text>
594
595 <xsl:text>\end{fvlisting}&#10;</xsl:text>
596
597 </xsl:template>
598
599 <!-- ==================================================================== -->
600
601 <xsl:template match="*" mode="filename.abs.get">
602 <xsl:choose>
603 <xsl:when test="@entityref">
604 <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
605 </xsl:when>
606 <xsl:when test="contains(@fileref, ':')">
607 <!-- absolute uri scheme -->
608 <xsl:value-of select="substring-after(@fileref, ':')"/>
609 </xsl:when>
610 <xsl:when test="starts-with(@fileref, '/')">
611 <!-- absolute unix like path -->
612 <xsl:value-of select="@fileref"/>
613 </xsl:when>
614 <xsl:otherwise>
615 <!-- relative to the doc directory -->
616 <xsl:value-of select="$current.dir"/>
617 <xsl:text>/</xsl:text>
618 <xsl:value-of select="@fileref"/>
619 </xsl:otherwise>
620 </xsl:choose>
621 </xsl:template>
622
623 </xsl:stylesheet>