-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconvert2HTML.xsl
112 lines (101 loc) · 5.4 KB
/
convert2HTML.xsl
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:bod="http://www.bodleian.ox.ac.uk/bdlss"
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="tei html xs bod"
version="2.0">
<xsl:import href="https://raw.githubusercontent.com/bodleian/consolidated-tei-schema/master/msdesc2html.xsl"/>
<!-- Only set this variable if you want full URLs hardcoded into the HTML
on the web site (previewManuscript.xsl overrides this to do so when previewing.) -->
<xsl:variable name="website-url" as="xs:string" select="''"/>
<!-- Any templates added below will override the templates in the shared
imported stylesheet, allowing customization of manuscript display for each catalogue. -->
<xsl:template name="Header">
<aside class="aside-navigation ">
<p>List of works:</p>
<table role="nav">
<xsl:apply-templates select="/TEI/teiHeader/fileDesc/sourceDesc/msDesc//msItem[title]" mode="fraglist"/>
<xsl:if test="count(/TEI/teiHeader/fileDesc/sourceDesc/msDesc//msItem[title]) eq 0">
<tr><td colspan="2"><xsl:text>No works have been identified in this manuscript.</xsl:text></td></tr>
</xsl:if>
</table>
</aside>
</xsl:template>
<xsl:template match="msItem" mode="fraglist">
<tr>
<td>
<xsl:variable name="titletext" select="normalize-space(string-join(title[1]//text()[not(ancestor::foreign)], ' '))"/>
<a href="{ concat('#', @xml:id) }" title="{ $titletext }">
<xsl:value-of select="bod:shortenToNearestWord($titletext, 48)"/>
</a>
</td>
<td>
<xsl:choose>
<xsl:when test="ancestor::msPart or .//locus">
<xsl:if test="ancestor::msPart and (ancestor::msPart//msItem[title])[1]/@xml:id = @xml:id">
<a href="{ concat('#', ancestor::msPart[1]/@xml:id) }">
<xsl:text>Part </xsl:text>
<xsl:value-of select="ancestor::msPart[1]/@n"/>
</a>
<xsl:if test=".//locus">
<br/>
</xsl:if>
</xsl:if>
<xsl:apply-templates select="(.//locus)[1]" mode="fraglist"/>
</xsl:when>
<xsl:otherwise>
<br/>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
<xsl:template match="locus" mode="fraglist">
<xsl:choose>
<xsl:when test="exists(.//text())">
<xsl:value-of select="normalize-space(string-join(.//text(), ' '))"/>
</xsl:when>
<xsl:when test="@from and @to">
<xsl:text>fols. </xsl:text>
<xsl:value-of select="@from"/>
<xsl:text>–</xsl:text>
<xsl:value-of select="@to"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="AdditionalContent">
<xsl:if test="starts-with(/TEI/@xml:id, 'volume_')">
<!-- Currently only Genizah has images -->
<div class="additional_content">
<xsl:if test="/TEI/teiHeader/fileDesc/sourceDesc/msDesc/additional/adminInfo/tei:recordHist/tei:source/tei:ref/@facs">
<h3>Catalogue Images</h3>
<ul style="list-style-type:none;">
<xsl:for-each select="tokenize(normalize-space(string-join(/TEI/teiHeader/fileDesc/sourceDesc/msDesc/additional/adminInfo/tei:recordHist/tei:source/tei:ref/@facs, ' ')), ' ')">
<li>
<a href="{ concat('/images/catalogue/', .) }"><xsl:value-of select="substring-before(substring-after(., '_'), '.jpg')"/></a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
<xsl:if test="/TEI/facsimile/graphic">
<h3>Fragment Images</h3>
<p style="float:right;">
<xsl:for-each select="/TEI/facsimile/graphic/@url">
<xsl:variable name="jpgfilename" select="replace(., '\.tiff*$', '.jpg')"/>
<xsl:variable name="fullsizefile" select="concat('/fragments/full/', $jpgfilename)"/>
<xsl:variable name="thumbfile" select="concat('/fragments/thumbs/', $jpgfilename)"/>
<xsl:variable name="folio" select="tokenize(substring-before($jpgfilename, '.jpg'), '_')[last()]"/>
<a href="{ $fullsizefile }" title="{ $folio }" style="display: inline-block; float:right;">
<img src="{ $thumbfile }" alt="Thumbnail of { $folio }" height="80"/>
</a>
</xsl:for-each>
</p>
</xsl:if>
</div>
</xsl:if>
</xsl:template>
</xsl:stylesheet>