Statistics
| Revision:

root / tmp / org.txm.oriflamms.rcp / res / 3-facsimile-pager.xsl @ 2398

History | View | Annotate | Download (7.7 kB)

1
<?xml version="1.0"?>
2
<xsl:stylesheet
3
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
	xmlns:tei="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="#all"
6
	version="2.0">
7
	<!-- This software is dual-licensed: 1. Distributed under a Creative Commons 
8
		Attribution-ShareAlike 3.0 Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
9
		2. http://www.opensource.org/licenses/BSD-2-Clause All rights reserved. Redistribution 
10
		and use in source and binary forms, with or without modification, are permitted 
11
		provided that the following conditions are met: * Redistributions of source 
12
		code must retain the above copyright notice, this list of conditions and 
13
		the following disclaimer. * Redistributions in binary form must reproduce 
14
		the above copyright notice, this list of conditions and the following disclaimer 
15
		in the documentation and/or other materials provided with the distribution. 
16
		This software is provided by the copyright holders and contributors "as is" 
17
		and any express or implied warranties, including, but not limited to, the 
18
		implied warranties of merchantability and fitness for a particular purpose 
19
		are disclaimed. In no event shall the copyright holder or contributors be 
20
		liable for any direct, indirect, incidental, special, exemplary, or consequential 
21
		damages (including, but not limited to, procurement of substitute goods or 
22
		services; loss of use, data, or profits; or business interruption) however 
23
		caused and on any theory of liability, whether in contract, strict liability, 
24
		or tort (including negligence or otherwise) arising in any way out of the 
25
		use of this software, even if advised of the possibility of such damage. 
26
		$Id$ This stylesheet is based on TEI processpb.xsl by Sebastian Rahtz available 
27
		at https://github.com/TEIC/Stylesheets/blob/master/tools/processpb.xsl and 
28
		is adapted by Alexei Lavrentiev to split an HTML edition for TXM platform. -->
29
	<xsl:output indent="no" method="xml" />
30

    
31
	<xsl:param name="css-name-txm">
32
		txm
33
	</xsl:param>
34
	<xsl:param name="css-name">
35
		tei
36
	</xsl:param>
37
	<xsl:param name="edition-name">
38
		facs
39
	</xsl:param>
40
	<xsl:param name="number-words-per-page">
41
		999999
42
	</xsl:param>
43
	<xsl:param name="pagination-element">
44
		pb
45
	</xsl:param>
46
	<xsl:param name="output-directory">
47
		<xsl:value-of
48
			select="concat($current-file-directory,'/',$edition-name)" />
49
	</xsl:param>
50
	<xsl:param name="image-directory">
51
		/home/alavrent/Bureau/Oriflamms_sources/mss-dates/mss-dates/img
52
	</xsl:param>
53
	<xsl:param name="word-element">
54
		w
55
	</xsl:param>
56

    
57
	<!-- /home/alavrent/Bureau/Oriflamms_sources/mss-dates/mss-dates/img -->
58

    
59
	<xsl:variable name="current-file-name">
60
		<xsl:analyze-string select="document-uri(.)"
61
			regex="^(.*)/([^/]+)\.[^/]+$">
62
			<xsl:matching-substring>
63
				<xsl:value-of select="regex-group(2)" />
64
			</xsl:matching-substring>
65
		</xsl:analyze-string>
66
	</xsl:variable>
67

    
68
	<xsl:variable name="current-file-directory">
69
		<xsl:analyze-string select="document-uri(.)"
70
			regex="^(.*)/([^/]+)\.[^/]+$">
71
			<xsl:matching-substring>
72
				<xsl:value-of select="regex-group(1)" />
73
			</xsl:matching-substring>
74
		</xsl:analyze-string>
75
	</xsl:variable>
76

    
77
	<xsl:variable as="xs:integer" name="page-number-adjust">
78
		<xsl:choose>
79
			<xsl:when test="$word-element='c'">
80
				1
81
			</xsl:when>
82
			<xsl:otherwise>
83
				2
84
			</xsl:otherwise>
85
		</xsl:choose>
86
	</xsl:variable>
87

    
88

    
89

    
90
	<xsl:template match="/">
91
		<dummy>
92
			<xsl:apply-templates
93
				select="descendant::*[local-name()=$pagination-element]" />
94
		</dummy>
95
		<xsl:if test="$word-element='w'">
96
			<xsl:result-document
97
				href="{$output-directory}/{$current-file-name}_1.html">
98
				<html>
99
					<head>
100
						<meta name="txm:first-word-id" content="w_0" />
101
						<title>
102
							<xsl:value-of
103
								select="concat($current-file-name,', Page de garde')" />
104
						</title>
105
						<meta http-equiv="Content-Type"
106
							content="text/html;charset=UTF-8" />
107
						<link rel="stylesheet" media="all" type="text/css"
108
							href="css/{$css-name-txm}.css" />
109
						<xsl:if test="matches($css-name,'\S')">
110
							<link rel="stylesheet" media="all" type="text/css"
111
								href="css/{$css-name}.css" />
112
						</xsl:if>
113
						<!--<xsl:copy-of select="$style"/> -->
114
					</head>
115
					<body>
116
						<div class="txmeditionpage">
117
							<h2>
118
								<xsl:value-of select="$current-file-name" />
119
							</h2>
120
							<h3>Reproductions des pages</h3>
121

    
122
						</div>
123
					</body>
124
				</html>
125
			</xsl:result-document>
126
		</xsl:if>
127
	</xsl:template>
128

    
129

    
130
	<xsl:template match="*[local-name()=$pagination-element]">
131
		<xsl:variable name="next-word-position" as="xs:integer">
132
			<xsl:choose>
133
				<xsl:when test="following::*[local-name()=$word-element]">
134
					<xsl:value-of
135
						select="count(following::*[local-name()=$word-element][1]/preceding::*[local-name()=$word-element])" />
136
				</xsl:when>
137
				<xsl:otherwise>
138
					0
139
				</xsl:otherwise>
140
			</xsl:choose>
141
		</xsl:variable>
142
		<xsl:variable name="next-pb-position" as="xs:integer">
143
			<xsl:choose>
144
				<xsl:when
145
					test="following::*[local-name()=$pagination-element]">
146
					<xsl:value-of
147
						select="count(following::*[local-name()=$pagination-element][1]/preceding::*[local-name()=$word-element])" />
148
				</xsl:when>
149
				<xsl:otherwise>
150
					999999999
151
				</xsl:otherwise>
152
			</xsl:choose>
153
		</xsl:variable>
154
		<xsl:variable name="next-word-id">
155
			<xsl:choose>
156
				<xsl:when
157
					test="$next-pb-position - $next-word-position = 999999999">
158
					w_0
159
				</xsl:when>
160
				<xsl:when test="$next-pb-position &gt; $next-word-position">
161
					<xsl:value-of
162
						select="following::*[local-name()=$word-element][1]/@id" />
163
				</xsl:when>
164
				<xsl:otherwise>
165
					w_0
166
				</xsl:otherwise>
167
			</xsl:choose>
168
		</xsl:variable>
169
		<xsl:variable name="pageId">
170
			<xsl:value-of select="@id" />
171
		</xsl:variable>
172
		<xsl:comment>
173
			Page
174
			<xsl:value-of select="@id" />
175
			enregistrée dans
176
			<xsl:value-of
177
				select="concat($output-directory,'/',$current-file-name,'_',count(preceding::*[local-name()=$pagination-element]) + $page-number-adjust,'.html')" />
178
		</xsl:comment>
179
		<xsl:result-document
180
			href="{$output-directory}/{$current-file-name}_{count(preceding::*[local-name()=$pagination-element]) + $page-number-adjust}.html">
181
			<html>
182
				<head>
183
					<meta name="txm:first-word-id" content="{$next-word-id}" />
184
					<title>
185
						<xsl:value-of
186
							select="concat($current-file-name,', Page ',@n)" />
187
					</title>
188
					<meta http-equiv="Content-Type"
189
						content="text/html;charset=UTF-8" />
190
					<link rel="stylesheet" media="all" type="text/css"
191
						href="css/{$css-name-txm}.css" />
192
					<xsl:if test="matches($css-name,'\S')">
193
						<link rel="stylesheet" media="all" type="text/css"
194
							href="css/{$css-name}.css" />
195
					</xsl:if>
196
					<script type="text/javascript"
197
						src="js/viewer/Simple_Viewer_beta_1.1-min.js">
198
						<xsl:text> </xsl:text>
199
					</script>
200
					<script type="text/javascript"
201
						src="js/viewer/toolbar-ext.js">
202
						<xsl:text> </xsl:text>
203
					</script>
204
					<link rel="stylesheet" type="text/css"
205
						href="js/viewer/toolbar-ext.css" />
206
					<!--<xsl:copy-of select="$style"/> -->
207
				</head>
208
				<body>
209
					<div class="txmeditionpage">
210
						<img src="{$image-directory}/{@facs}"
211
							alt="Image {@id} indisponible"
212
							onLoad="viewer.toolbarImages='images/icons';viewer.onload=viewer.toolbar;new viewer({{image: this, frame: ['100%','100%']}});"></img>
213
						<!--<span class="invisible" id="{following::tei:w[1]/@id}"></span> -->
214
						<span class="invisible" id="{$next-word-id}"></span>
215

    
216
					</div>
217
				</body>
218
			</html>
219
		</xsl:result-document>
220

    
221
	</xsl:template>
222

    
223

    
224
</xsl:stylesheet>