forked from leoba/ebooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathebook-generation-BiblioPhilly.xsl
116 lines (96 loc) · 6.66 KB
/
ebook-generation-BiblioPhilly.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
113
114
115
116
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="tei" version="2.0">
<xsl:template match="/">
<xsl:variable name="mstitle" select="substring(//tei:titleStmt/tei:title,16)"/>
<xsl:variable name="summary" select="//tei:summary"/>
<xsl:variable name="recordURL" select="//tei:altIdentifier[@type='resource']/tei:idno"/>
<xsl:variable name="callNo" select="//tei:idno[@type='call-number']"/>
<xsl:variable name="baseURL">http://openn.library.upenn.edu/Data/</xsl:variable>
<xsl:variable name="teiFileNameURI" select="document-uri(/)"/>
<xsl:variable name="teiFileName" select="tokenize($teiFileNameURI,'/')[position() = last()]"/>
<xsl:variable name="msCode" select="replace($teiFileName,'_TEI.xml','')"/>
<xsl:variable name="repository_code">
<xsl:choose>
<xsl:when test="starts-with($callNo,'Othmer')">0025</xsl:when>
<xsl:when test="starts-with($callNo,'Lewis')">0023</xsl:when>
<xsl:otherwise>you need to add a new when test</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:result-document href="input/{$msCode}.html">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Facsimile of <xsl:value-of select="$mstitle"/></title>
<style type="text/css">
hr {page-break-after:always;}
</style>
</head>
<body>
<h3>Facsimile of <xsl:value-of select="$mstitle"/></h3>
<p>
<xsl:value-of select="$summary"/>
</p>
<hr/>
<p>The manuscript contained in this facsimile is the <xsl:choose>
<xsl:when test="$recordURL != ''"><a href="{$recordURL}"><xsl:value-of select="$mstitle"/></a></xsl:when>
<xsl:otherwise><xsl:value-of select="$mstitle"/></xsl:otherwise>
</xsl:choose>.</p>
<p>To read descriptions of illustrations, figures, or initials on a page, click on the page image.</p>
<p>Digital images are courtesy of <a href="http://openn.library.upenn.edu/"
>OPenn, Making Primary Sources Available to Everyone</a>, hosted by the
University of Pennsylvania Libraries.</p>
<hr/>
<xsl:choose>
<xsl:when test="string-length($summary) > 500"/>
<xsl:otherwise><p>[This page left purposefully blank.]</p><hr/></xsl:otherwise>
</xsl:choose>
<xsl:for-each select="//tei:surface">
<xsl:variable name="folNo" select="replace(replace(@n,' ',''),',','')"/>
<xsl:variable name="id"><xsl:number format="001"/>-<xsl:value-of select="$folNo"/></xsl:variable>
<!--<xsl:if test="matches($folNo, '\d+r') or matches($folNo, '\d+v') or matches($folNo, '^\d+') or matches($folNo, '^\d+')">-->
<xsl:for-each select="tei:graphic[starts-with(@url,'web')]">
<xsl:variable name="img" select="substring(@url,5)"/>
<xsl:variable name="full_path_to_img" select="concat($baseURL,$repository_code,'/',$msCode,'/data/',@url)"/>
<!-- When you are using this to create an ebook you will need to have the images locally. In that case use this bit of code -->
<p>
<a href="#{$id}" name="img-{$id}" title="Folio {$folNo}"><img src="{$img}" alt="{$folNo}"/></a>
</p>
<!-- When you will be using this for other reasons - and you don't have the images locally - comment the code above and uncomment this -->
<p>
<a href="#{$id}" name="img-{$id}" title="Folio {$folNo}"><img src="{$full_path_to_img}" alt="{$folNo}"/></a>
</p>
</xsl:for-each>
<!--</xsl:if>-->
</xsl:for-each>
<xsl:for-each select="//tei:surface">
<xsl:variable name="folNo" select="replace(replace(@n,' ',''),',','')"/>
<xsl:variable name="id"><xsl:number format="001"/>-<xsl:value-of select="$folNo"/></xsl:variable>
<!--<xsl:if test="matches($folNo, '\d+r') or matches($folNo, '\d+v') or matches($folNo, '^\d+') or matches($folNo, '^\d+')">-->
<!-- This originally tested for foliation or pagination but I don't think that's right so I'm removing the if test -->
<xsl:for-each select="tei:graphic[starts-with(@url,'web')]">
<xsl:variable name="img" select="substring(@url,5)"/>
<xsl:variable name="full_path_to_img" select="concat($baseURL,$repository_code,'/',$msCode,'/data/',@url)"/>
<p><a href="#img-{$id}" name="{$id}">Back to image</a></p>
<xsl:if test="not(//tei:msItem[@n=$folNo]) and not(//tei:decoNote[@n=$folNo])">
<p>There are no illustrations, figures, or initials on this page.</p>
</xsl:if>
<xsl:for-each select="//tei:msItem[@n=$folNo]">
<p>
<xsl:value-of select="tei:title"/>
</p>
</xsl:for-each>
<xsl:for-each select="//tei:decoNote[@n=$folNo]">
<p>
<xsl:value-of select="."/>
</p>
</xsl:for-each>
<p><a href="{$full_path_to_img}">If you are connected to the Internet, view a high-resolution version of this image in a browser.</a></p>
</xsl:for-each>
<hr/>
</xsl:for-each>
</body>
</html>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>