-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathABBYY-to-TEIv2.xsl
119 lines (107 loc) · 6.28 KB
/
ABBYY-to-TEIv2.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
117
118
119
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.abbyy.com/FineReader_xml/FineReader8-schema-v2.xml"
xpath-default-namespace="http://www.abbyy.com/FineReader_xml/FineReader8-schema-v2.xml">
<xsl:output method="xml" version="1.0" encoding="UTF-8"/>
<!-- Require the MARC id as a parameter marcid=XXXXXX - this is the record ID from the Library catalogue -->
<xsl:param name="marcid" required="yes"/>
<!-- =================================================================== -->
<!-- Document root -->
<!-- =================================================================== -->
<xsl:template match="/">
<xsl:text> </xsl:text>
<xsl:processing-instruction name="oxygen">
<xsl:text>RNGSchema="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/teilite.rng" type="xml"</xsl:text>
</xsl:processing-instruction>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<xsl:text> </xsl:text>
<!-- We're include the TEI header that was transformed from the MARC record into a -->
<!-- temporary file at /tmp/tei_header.xml -->
<xsl:copy-of select="document('/tmp/tei_header.xml')"/><xsl:text> </xsl:text>
<text> <xsl:text> </xsl:text>
<body><xsl:text> </xsl:text>
<xsl:apply-templates select="document/page"/>
</body>
</text> <xsl:text> </xsl:text>
</TEI>
</xsl:template>
<xsl:template match="page">
<div type="page" xmlns="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="n"><xsl:value-of select="position()-1"/></xsl:attribute><xsl:text> </xsl:text>
<xsl:comment>This is scanned page number <xsl:value-of select="position()-1"/> of the work <xsl:value-of select="$marcid"/>.</xsl:comment><xsl:text> </xsl:text>
<pb xmlns="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="n"><xsl:value-of select="position()-1"/></xsl:attribute>
<!-- <xsl:attribute name="xml:id"><xsl:value-of select="generate-id()"/></xsl:attribute>
<xsl:attribute name="facs">/fedora/repository/ilives:<xsl:value-of select="$marcid"/>-<xsl:number value="position()-1" format="000"/>/JP2/JP2.jp2</xsl:attribute> -->
</pb>
<xsl:apply-templates/>
</div><xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="block[@blockType='Text']">
<div xmlns="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="n"><xsl:value-of select="generate-id()"/></xsl:attribute>
<!-- <xsl:attribute name="xml:id"><xsl:value-of select="generate-id()"/></xsl:attribute> -->
<xsl:attribute name="rend"><xsl:value-of select="@l"/>,<xsl:value-of select="@t"/>,<xsl:value-of select="@r"/>,<xsl:value-of select="@b"/></xsl:attribute>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="block[@blockType='Text']/text/par">
<p xmlns="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="n"><xsl:value-of select="generate-id()"/></xsl:attribute>
<!-- <xsl:attribute name="xml:id"><xsl:value-of select="generate-id()"/></xsl:attribute> -->
<xsl:apply-templates/></p>
</xsl:template>
<!--
<xsl:template match="block[@blockType='Text']/text/par/line">
<seg xmlns="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="n"><xsl:value-of select="generate-id()"/></xsl:attribute>
<xsl:attribute name="xml:id"><xsl:value-of select="generate-id()"/></xsl:attribute>
<xsl:attribute name="rend"><xsl:value-of select="@l"/>,<xsl:value-of select="@t"/>,<xsl:value-of select="@r"/>,<xsl:value-of select="@b"/></xsl:attribute>
<xsl:apply-templates/><lb xmlns="http://www.tei-c.org/ns/1.0"/>
</seg>
</xsl:template>
-->
<xsl:template match="block[@blockType='Table']">
<div xmlns="http://www.tei-c.org/ns/1.0"><table xmlns="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="n"><xsl:value-of select="generate-id()"/></xsl:attribute>
<!-- <xsl:attribute name="xml:id"><xsl:value-of select="generate-id()"/></xsl:attribute> -->
<xsl:attribute name="rend"><xsl:value-of select="@l"/>,<xsl:value-of select="@t"/>,<xsl:value-of select="@r"/>,<xsl:value-of select="@b"/></xsl:attribute>
<xsl:apply-templates/>
</table></div>
</xsl:template>
<xsl:template match="row">
<row xmlns="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="n"><xsl:value-of select="generate-id()"/></xsl:attribute>
<!-- <xsl:attribute name="xml:id"><xsl:value-of select="generate-id()"/></xsl:attribute> -->
<xsl:apply-templates/></row>
</xsl:template>
<xsl:template match="cell">
<cell xmlns="http://www.tei-c.org/ns/1.0">
<xsl:apply-templates/></cell>
</xsl:template>
<xsl:template match="block[@blockType='Picture']">
<div xmlns="http://www.tei-c.org/ns/1.0"><xsl:text> </xsl:text>
<figure xmlns="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="n"><xsl:value-of select="generate-id()"/></xsl:attribute>
<!-- <xsl:attribute name="xml:id"><xsl:value-of select="generate-id()"/></xsl:attribute> -->
<xsl:attribute name="rend"><xsl:value-of select="@l"/>,<xsl:value-of select="@t"/>,<xsl:value-of select="@r"/>,<xsl:value-of select="@b"/></xsl:attribute>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
</figure><xsl:text> </xsl:text>
</div><xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="block[@blockType='Picture']/region/rect">
<graphic xmlns="http://www.tei-c.org/ns/1.0">
<xsl:attribute name="n"><xsl:value-of select="generate-id()"/></xsl:attribute>
<xsl:attribute name="rend"><xsl:value-of select="@l"/>,<xsl:value-of select="@t"/>,<xsl:value-of select="@r"/>,<xsl:value-of select="@b"/></xsl:attribute>
<xsl:text> </xsl:text>
<!-- <xsl:attribute name="xml:id"><xsl:value-of select="generate-id()"/></xsl:attribute>
<xsl:attribute name="width"><xsl:value-of select="@r - @l"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="@b - @t"/></xsl:attribute>
<xsl:attribute name="url">/fedora/repository/ilives:<xsl:value-of select="$marcid"/>-<xsl:number value="count(ancestor::page/preceding-sibling::*)+1" format="000" />-<xsl:number level="any" count="block[@blockType='Picture']/region/rect" from="page" format="000" />/JPG/JPG.jpg</xsl:attribute> -->
<xsl:apply-templates/>
</graphic>
</xsl:template>
</xsl:stylesheet>