summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/bibtex/bibhtml/bibhtml-extract-aux.xslt
blob: 2862c56dba432894cb1d3181bb40eea523bce975 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?xml version="1.0" encoding="UTF-8"?>
<!--
 ! bibhtml-extract-aux.xslt
 !
 ! Part of bibhtml, version 2.0.1, released 2009 November 2
 ! Hg Node 6ca3807543d6.
 ! See <http://purl.org/nxg/dist/bibhtml>
 !
 ! This sample script processes an XML file which contains elements like
 ! <span class='cite'>citation</span>, extracting each of the `citation'
 ! strings and emitting a .aux file which, once a \bibdata line has been
 ! appended, is suitable for processing with BibTeX.  Adapt or extend as
 ! appropriate.
 !-->
<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform"
                version="1.0"
                exclude-result-prefixes="h"
                xmlns:h="http://www.w3.org/1999/xhtml">

  <output method="xml"
            version="1.0"
            doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
            omit-xml-declaration="yes"/>

  <template match="/">
    <text>\relax
</text>
    <apply-templates select="//h:span[@class='cite']"/>
    <apply-templates select='//processing-instruction("bibliography")'/>
    <!--
    <call-template name="make-tex-command">
      <with-param name="command">bibstyle</with-param>
      <with-param name="content">plainhtml</with-param>
    </call-template>
    -->
  </template>

  <template match="h:span[@class='cite']">
    <!--
    <h:a>
      <attribute name='href'>
        <text>#</text>
        <copy-of select='.'/>
      </attribute>
      <copy-of select='.'/>
    </h:a>
    -->
    <call-template name="make-tex-command">
      <with-param name="command">citation</with-param>
      <with-param name="content">
        <copy-of select="."/>
      </with-param>
    </call-template>
  </template>

  <template match='processing-instruction("bibliography")'>
    <choose>
      <when test='string-length(.) = 0'>
        <text>% No bibliography file specified!
</text>
      </when>
      <when test='contains(.," ")'>
        <call-template name='make-tex-command'>
          <with-param name='command'>bibdata</with-param>
          <with-param name='content'>
            <value-of select='substring-before(.," ")'/>
          </with-param>
        </call-template>
        <call-template name='make-tex-command'>
          <with-param name='command'>bibstyle</with-param>
          <with-param name='content'>
            <value-of select='substring-after(.," ")'/>
          </with-param>
        </call-template>
      </when>
      <otherwise>
        <call-template name='make-tex-command'>
          <with-param name='command'>bibdata</with-param>
          <with-param name='content'>
            <value-of select='normalize-space(.)'/>
          </with-param>
        </call-template>
      </otherwise>
    </choose>
  </template>  

  <template name="make-tex-command">
    <param name="command"/>
    <param name="content"/>
    <text>\</text>
    <value-of select="$command"/>
    <text>{</text>
    <value-of select="$content"/>
    <text>}
</text>
  </template>

</stylesheet>