File: harvard-helper.xsl

package info (click to toggle)
bodr 10-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,548 kB
  • sloc: xml: 29,107; sh: 494; makefile: 182
file content (144 lines) | stat: -rw-r--r-- 3,863 bytes parent folder | download | duplicates (5)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
		xmlns:bibtex="http://bibtexml.sf.net/"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="text()">
    <xsl:value-of select="normalize-space(.)"/>
  </xsl:template>

  <xsl:template name="author">
    <xsl:apply-templates select="bibtex:author|bibtex:editor"/>
    <xsl:text> </xsl:text>
    <xsl:apply-templates select="bibtex:year"/>
    <xsl:text>, </xsl:text>
  </xsl:template>

  <xsl:template match="bibtex:chapter">
    <xsl:text>`</xsl:text>
    <xsl:choose>
      <xsl:when test="bibtex:title">
	<xsl:value-of select="bibtex:title"/>
	<xsl:if test="bibtex:subtitle">
	  <xsl:text>: </xsl:text>
	  <xsl:value-of select="bibtex:subtitle"/>
	</xsl:if>
      </xsl:when>
      <xsl:otherwise>
	<xsl:apply-templates />
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text>' in </xsl:text>
  </xsl:template>


  <xsl:template name="publisher">
    <xsl:apply-templates select="bibtex:edition"/>
    <xsl:apply-templates
	select="bibtex:publisher|bibtex:organization|bibtex:institution"/>
    <xsl:apply-templates select="bibtex:address"/>
  </xsl:template>

  <xsl:template match="
         bibtex:publisher|bibtex:organization|bibtex:institution|
	 bibtex:edition|bibtex:address">
    <xsl:text>, </xsl:text>
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="bibtex:pages">
    <xsl:choose>
      <xsl:when test="contains(.,'-')">
	<xsl:text>, pp.</xsl:text>
      </xsl:when>
      <xsl:otherwise>
	<xsl:text>, p.</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="bibtex:volume">
    <xsl:text>, vol.</xsl:text>
    <xsl:apply-templates />
  </xsl:template>
  <xsl:template match="bibtex:number">
    <xsl:text>, no.</xsl:text>
    <xsl:apply-templates />
  </xsl:template>

  <!-- why does this not work?
  <xsl:template match="bibtex:first|bibtex:middle">
    <xsl:value-of select="substring(.,0,2)" />
    <xsl:text>.</xsl:text>
  </xsl:template>
  -->

  <xsl:template match="bibtex:person">
    <xsl:choose>
      <xsl:when test="bibtex:last">
	<xsl:apply-templates select="bibtex:last"/>
	<xsl:text>, </xsl:text>
	<xsl:choose>
	  <xsl:when test="bibtex:initials">
	    <xsl:apply-templates select="bibtex:initials"/>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:if test="bibtex:first">
	      <xsl:value-of select="substring(bibtex:first,0,2)" />
	      <xsl:text>.</xsl:text>
	    </xsl:if>
	    <xsl:if test="bibtex:middle">
	      <xsl:value-of select="substring(bibtex:middle,0,2)" />
	      <xsl:text>.</xsl:text>
	    </xsl:if>
	    <!--
		<xsl:apply-templates select="bibtex:first"/>
		<xsl:apply-templates select="bibtex:middle"/>
	    -->
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:when>
      <xsl:otherwise>
	<xsl:apply-templates/>
      </xsl:otherwise>      
    </xsl:choose>
    <xsl:choose>
      <xsl:when test="position()=last()-1">
	<xsl:text> &amp; </xsl:text>
      </xsl:when>
      <xsl:when test="not(position()=last())">
	<xsl:text>, </xsl:text>
      </xsl:when>
    </xsl:choose>
  </xsl:template>


  <xsl:template name="editor-add-text">
    <xsl:if test="name()='bibtex:editor'">
      <xsl:choose>
	<xsl:when test="count(bibtex:person)>1">
	  <xsl:text> (eds)</xsl:text>
	</xsl:when>
	<xsl:otherwise>
	  <xsl:text> (ed.)</xsl:text>
	</xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>

  <xsl:template match="bibtex:editor">
    <!--  Conflicts with rule in html-linkify.  -->
    <xsl:apply-templates/>
    <xsl:call-template name="editor-add-text"/>
  </xsl:template>

  <xsl:template match="bibtex:doi|bibtex:isbn|bibtex:issn|bibtex:lccn">
    <xsl:text>, </xsl:text>
    <xsl:value-of select='substring-after(name(.),"bibtex:")'/>
    <xsl:text>:</xsl:text>
    <xsl:apply-templates />
  </xsl:template>


</xsl:stylesheet>