Revision 2398 tmp/org.txm.oriflamms.rcp/groovy/org/txm/macro/oriflamms/prepare/3-facsimile-pager.xsl

3-facsimile-pager.xsl (revision 2398)
2 2
<xsl:stylesheet
3 3
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 4
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
	xmlns:tei="http://www.tei-c.org/ns/1.0"
6
	exclude-result-prefixes="#all"
7
	version="2.0" >
8
	<!--
9
This software is dual-licensed:
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" />
10 30

  
11
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
12
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
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>
13 56

  
14
2. http://www.opensource.org/licenses/BSD-2-Clause
15
		
16
All rights reserved.
57
	<!-- /home/alavrent/Bureau/Oriflamms_sources/mss-dates/mss-dates/img -->
17 58

  
18
Redistribution and use in source and binary forms, with or without
19
modification, are permitted provided that the following conditions are
20
met:
21

  
22
* Redistributions of source code must retain the above copyright
23
notice, this list of conditions and the following disclaimer.
24

  
25
* Redistributions in binary form must reproduce the above copyright
26
notice, this list of conditions and the following disclaimer in the
27
documentation and/or other materials provided with the distribution.
28

  
29
This software is provided by the copyright holders and contributors
30
"as is" and any express or implied warranties, including, but not
31
limited to, the implied warranties of merchantability and fitness for
32
a particular purpose are disclaimed. In no event shall the copyright
33
holder or contributors be liable for any direct, indirect, incidental,
34
special, exemplary, or consequential damages (including, but not
35
limited to, procurement of substitute goods or services; loss of use,
36
data, or profits; or business interruption) however caused and on any
37
theory of liability, whether in contract, strict liability, or tort
38
(including negligence or otherwise) arising in any way out of the use
39
of this software, even if advised of the possibility of such damage.
40

  
41
     $Id$
42
     
43
This stylesheet is based on TEI processpb.xsl by Sebastian Rahtz 
44
available at 
45
https://github.com/TEIC/Stylesheets/blob/master/tools/processpb.xsl 
46
and is adapted by Alexei Lavrentiev to split an HTML edition for 
47
TXM platform.
48

  
49
  -->
50
	<xsl:output indent="no" method="xml"/>
51
	
52
	<xsl:param name="css-name-txm">txm</xsl:param>
53
	<xsl:param name="css-name">tei</xsl:param>
54
	<xsl:param name="edition-name">facs</xsl:param>
55
	<xsl:param name="number-words-per-page">999999</xsl:param>
56
	<xsl:param name="pagination-element">pb</xsl:param>
57
	<xsl:param name="output-directory"><xsl:value-of select="concat($current-file-directory,'/',$edition-name)"/></xsl:param>
58
	<xsl:param name="image-directory">/home/alavrent/Bureau/Oriflamms_sources/mss-dates/mss-dates/img</xsl:param>
59
	<xsl:param name="word-element">w</xsl:param>
60
	
61
	<!-- /home/alavrent/Bureau/Oriflamms_sources/mss-dates/mss-dates/img -->
62
	
63 59
	<xsl:variable name="current-file-name">
64
		<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$">
60
		<xsl:analyze-string select="document-uri(.)"
61
			regex="^(.*)/([^/]+)\.[^/]+$">
65 62
			<xsl:matching-substring>
66
				<xsl:value-of select="regex-group(2)"/>
63
				<xsl:value-of select="regex-group(2)" />
67 64
			</xsl:matching-substring>
68 65
		</xsl:analyze-string>
69 66
	</xsl:variable>
70
	
67

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

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

  
88

  
89

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

  
106 122
						</div>
107 123
					</body>
108 124
				</html>
109
			</xsl:result-document>			
110
		</xsl:if>		
125
			</xsl:result-document>
126
		</xsl:if>
111 127
	</xsl:template>
112
	
113
	
128

  
129

  
114 130
	<xsl:template match="*[local-name()=$pagination-element]">
115 131
		<xsl:variable name="next-word-position" as="xs:integer">
116 132
			<xsl:choose>
117 133
				<xsl:when test="following::*[local-name()=$word-element]">
118
					<xsl:value-of select="count(following::*[local-name()=$word-element][1]/preceding::*[local-name()=$word-element])"/>
134
					<xsl:value-of
135
						select="count(following::*[local-name()=$word-element][1]/preceding::*[local-name()=$word-element])" />
119 136
				</xsl:when>
120
				<xsl:otherwise>0</xsl:otherwise>
137
				<xsl:otherwise>
138
					0
139
				</xsl:otherwise>
121 140
			</xsl:choose>
122 141
		</xsl:variable>
123 142
		<xsl:variable name="next-pb-position" as="xs:integer">
124 143
			<xsl:choose>
125
				<xsl:when test="following::*[local-name()=$pagination-element]">
126
					<xsl:value-of select="count(following::*[local-name()=$pagination-element][1]/preceding::*[local-name()=$word-element])"/>
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])" />
127 148
				</xsl:when>
128
				<xsl:otherwise>999999999</xsl:otherwise>
149
				<xsl:otherwise>
150
					999999999
151
				</xsl:otherwise>
129 152
			</xsl:choose>
130 153
		</xsl:variable>
131 154
		<xsl:variable name="next-word-id">
132 155
			<xsl:choose>
133
				<xsl:when test="$next-pb-position - $next-word-position = 999999999">w_0</xsl:when>
134
				<xsl:when test="$next-pb-position &gt; $next-word-position"><xsl:value-of select="following::*[local-name()=$word-element][1]/@id"/></xsl:when>
135
				<xsl:otherwise>w_0</xsl:otherwise>
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>
136 167
			</xsl:choose>
137 168
		</xsl:variable>
138
		<xsl:variable name="pageId"><xsl:value-of select="@id"/></xsl:variable>
139
						<xsl:comment> Page <xsl:value-of select="@id"/> enregistrée dans <xsl:value-of select="concat($output-directory,'/',$current-file-name,'_',count(preceding::*[local-name()=$pagination-element]) + $page-number-adjust,'.html')"/></xsl:comment>
140
		<xsl:result-document href="{$output-directory}/{$current-file-name}_{count(preceding::*[local-name()=$pagination-element]) + $page-number-adjust}.html">
141
							<html>
142
								<head>
143
									<meta name="txm:first-word-id" content="{$next-word-id}"/>
144
									<title><xsl:value-of select="concat($current-file-name,', Page ',@n)"/></title>
145
									<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
146
									<link rel="stylesheet" media="all" type="text/css" href="css/{$css-name-txm}.css"/>
147
									<xsl:if test="matches($css-name,'\S')"><link rel="stylesheet" media="all" type="text/css" href="css/{$css-name}.css"/></xsl:if>
148
									<script type="text/javascript" src="js/viewer/Simple_Viewer_beta_1.1-min.js"><xsl:text> </xsl:text></script>
149
									<script type="text/javascript" src="js/viewer/toolbar-ext.js"><xsl:text> </xsl:text></script>
150
									<link rel="stylesheet" type="text/css" href="js/viewer/toolbar-ext.css" />
151
									<!--<xsl:copy-of select="$style"/>-->
152
								</head>
153
								<body>
154
									<div class="txmeditionpage">
155
										<img src="{$image-directory}/{@facs}"
156
											alt="Image {@id} indisponible" onLoad="viewer.toolbarImages='images/icons';viewer.onload=viewer.toolbar;new viewer({{image: this, frame: ['100%','100%']}});"></img>
157
										<!--<span class="invisible" id="{following::tei:w[1]/@id}"></span>-->
158
										<span class="invisible" id="{$next-word-id}"></span>
159
										
160
									</div>
161
								</body>
162
							</html>
163
						</xsl:result-document>
164
						
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

  
165 221
	</xsl:template>
166
	
167
		
222

  
223

  
168 224
</xsl:stylesheet>

Also available in: Unified diff