Statistics
| Revision:

root / tmp / org.txm.core / bin / org / txm / macro / oriflamms / prepare / 3-facsimile-pager.xsl @ 54

History | View | Annotate | Download (7.4 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"
6
	exclude-result-prefixes="#all"
7
	version="2.0" >
8
	<!--
9
This software is dual-licensed:
10

    
11
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
12
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
13

    
14
2. http://www.opensource.org/licenses/BSD-2-Clause
15
		
16
All rights reserved.
17

    
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
	<xsl:variable name="current-file-name">
64
		<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$">
65
			<xsl:matching-substring>
66
				<xsl:value-of select="regex-group(2)"/>
67
			</xsl:matching-substring>
68
		</xsl:analyze-string>
69
	</xsl:variable>
70
	
71
	<xsl:variable name="current-file-directory">
72
		<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$">
73
			<xsl:matching-substring>
74
				<xsl:value-of select="regex-group(1)"/>
75
			</xsl:matching-substring>
76
		</xsl:analyze-string>
77
	</xsl:variable>
78
	
79
	<xsl:variable as="xs:integer" name="page-number-adjust">
80
		<xsl:choose>
81
			<xsl:when test="$word-element='c'">1</xsl:when>
82
			<xsl:otherwise>2</xsl:otherwise>
83
		</xsl:choose>
84
	</xsl:variable>
85
	
86
	
87
	
88
	<xsl:template match="/">
89
		<dummy><xsl:apply-templates select="descendant::*[local-name()=$pagination-element]"/></dummy>
90
		<xsl:if test="$word-element='w'">
91
			<xsl:result-document href="{$output-directory}/{$current-file-name}_1.html">
92
				<html>
93
					<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
					</head>
101
					<body>
102
						<div class="txmeditionpage">
103
							<h2><xsl:value-of select="$current-file-name"/></h2>
104
							<h3>Reproductions des pages</h3>
105
							
106
						</div>
107
					</body>
108
				</html>
109
			</xsl:result-document>			
110
		</xsl:if>		
111
	</xsl:template>
112
	
113
	
114
	<xsl:template match="*[local-name()=$pagination-element]">
115
		<xsl:variable name="next-word-position" as="xs:integer">
116
			<xsl:choose>
117
				<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])"/>
119
				</xsl:when>
120
				<xsl:otherwise>0</xsl:otherwise>
121
			</xsl:choose>
122
		</xsl:variable>
123
		<xsl:variable name="next-pb-position" as="xs:integer">
124
			<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])"/>
127
				</xsl:when>
128
				<xsl:otherwise>999999999</xsl:otherwise>
129
			</xsl:choose>
130
		</xsl:variable>
131
		<xsl:variable name="next-word-id">
132
			<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>
136
			</xsl:choose>
137
		</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
						
165
	</xsl:template>
166
	
167
		
168
</xsl:stylesheet>