/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to xml.files/odt/common/measure_conversion.xsl

  • Committer: Suren A. Chilingaryan
  • Date: 2009-02-16 09:27:17 UTC
  • Revision ID: csa@dside.dyndns.org-20090216092717-wipyvaaw2srxhgns
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
<!--
 
3
 
 
4
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
5
  
 
6
  Copyright 2008 by Sun Microsystems, Inc.
 
7
 
 
8
  OpenOffice.org - a multi-platform office productivity suite
 
9
 
 
10
  $RCSfile: measure_conversion.xsl,v $
 
11
 
 
12
  $Revision: 1.9 $
 
13
 
 
14
  This file is part of OpenOffice.org.
 
15
 
 
16
  OpenOffice.org is free software: you can redistribute it and/or modify
 
17
  it under the terms of the GNU Lesser General Public License version 3
 
18
  only, as published by the Free Software Foundation.
 
19
 
 
20
  OpenOffice.org is distributed in the hope that it will be useful,
 
21
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
  GNU Lesser General Public License version 3 for more details
 
24
  (a copy is included in the LICENSE file that accompanied this code).
 
25
 
 
26
  You should have received a copy of the GNU Lesser General Public License
 
27
  version 3 along with OpenOffice.org.  If not, see
 
28
  <http://www.openoffice.org/license.html>
 
29
  for a copy of the LGPLv3 License.
 
30
 
 
31
-->
 
32
<!--
 
33
        For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
 
34
-->
 
35
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
36
        <!-- DPI (dots per inch) the standard resolution of given pictures (necessary for the conversion of 'cm' into 'pixel')
 
37
                 Although many pictures have a 96 dpi resolution, a higher resoltion give better results for common browsers -->
 
38
        <xsl:param name="dpi" select="111"/>
 
39
        <xsl:param name="centimeter-in-mm" select="10"/>
 
40
        <xsl:param name="inch-in-mm" select="25.4"/>
 
41
        <xsl:param name="didot-point-in-mm" select="0.376065"/>
 
42
        <xsl:param name="pica-in-mm" select="4.2333333"/>
 
43
        <xsl:param name="point-in-mm" select="0.3527778"/>
 
44
        <xsl:param name="twip-in-mm" select="0.017636684"/>
 
45
        <xsl:param name="pixel-in-mm" select="$inch-in-mm div $dpi"/>
 
46
        <!-- ***** MEASUREMENT CONVERSIONS *****
 
47
          PARAM 'value'
 
48
                The measure to be converted.
 
49
                The current measure is judged by a substring (e.g. 'mm', 'cm', 'in', 'pica'...)
 
50
                directly added to the number.
 
51
 
 
52
          PARAM 'rounding-factor'
 
53
                Is used for the rounding of decimal places.
 
54
                The parameter number is the product of 1 and some '10', where
 
55
                every zero represents a decimal place.
 
56
 
 
57
                For example, providing as parameter:
 
58
                        <xsl:param name="rounding-factor" select="10000" />
 
59
                Gives by default four decimal places.
 
60
 
 
61
                To round two decimal places, basically the following is done:
 
62
                        <xsl:value-of select="round(100 * value) div 100"/>
 
63
 
 
64
          RETURN    The converted number, by default rounded to four decimal places.
 
65
                                In case the input measure could not be matched the same value is
 
66
                                returned and a warning message is written out.
 
67
 
 
68
 
 
69
 
 
70
         MEASURE LIST:
 
71
         * 1 milimeter (mm), the basic measure
 
72
 
 
73
         * 1 centimeter (cm) = 10 mm
 
74
 
 
75
         * 1 inch (in) = 25.4 mm
 
76
                While the English have already seen the light (read: the metric system), the US
 
77
                remains loyal to this medieval system.
 
78
 
 
79
         * 1 point (pt) = 0.35277777.. mm
 
80
                Sometimes called PostScript point (ppt), as when Adobe created PostScript, they added their own system of points.
 
81
                There are exactly 72 PostScript points in 1 inch.
 
82
 
 
83
         * 1 twip = twentieth of a (PostScript) point
 
84
                A twip (twentieth of a point) is a 1/20th of a PostScript point, a traditional measure in printing.
 
85
 
 
86
         * 1 didot point (dpt) = 0.376065 mm
 
87
                Didot point after the French typographer Firmin Didot (1764-1836).
 
88
 
 
89
                More details under
 
90
                http://www.unc.edu/~rowlett/units/dictP.html:
 
91
                "A unit of length used by typographers and printers. When printing was done
 
92
                from hand-set metal type, one point represented the smallest element of type
 
93
                that could be handled, roughly 1/64 inch. Eventually, the point was standardized
 
94
                in Britain and America as exactly 1/72.27 = 0.013 837 inch, which is
 
95
                about 0.35 mm (351.46 micrometers). In continental Europe, typographers
 
96
                traditionally used a slightly larger point of 0.014 83 inch (about
 
97
                1/72 pouce, 0.377 mm, or roughly 1/67 English inch), called a Didot point
 
98
                after the French typographer Firmin Didot (1764-1836). In the U.S.,
 
99
                Adobe software defines the point to be exactly 1/72 inch (0.013 888 9 inch
 
100
                or 0.352 777 8 millimeters) and TeX software uses a slightly smaller point
 
101
                of 0.351 459 8035 mm. The German standards agency DIN has proposed that
 
102
                all these units be replaced by multiples of 0.25 millimeters (1/101.6 inch).
 
103
 
 
104
         * 1 pica = 4.233333 mm
 
105
                1/6 inch or 12 points
 
106
 
 
107
         * 1 pixel (px) = 0.26458333.. mm   (relative to 'DPI', here: 96 dpi)
 
108
                Most pictures have the 96 dpi resolution, but the dpi variable may vary by stylesheet parameter
 
109
 
 
110
 
 
111
        -->
 
112
        <!-- changing measure to mm -->
 
113
        <xsl:template name="convert2mm">
 
114
                <xsl:param name="value"/>
 
115
                <xsl:param name="rounding-factor" select="10000"/>
 
116
                <xsl:choose>
 
117
                        <xsl:when test="contains($value, 'mm')">
 
118
                                <xsl:value-of select="substring-before($value, 'mm')"/>
 
119
                        </xsl:when>
 
120
                        <xsl:when test="contains($value, 'cm')">
 
121
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm' ) * $centimeter-in-mm)) div $rounding-factor"/>
 
122
                        </xsl:when>
 
123
                        <xsl:when test="contains($value, 'in')">
 
124
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in' ) * $inch-in-mm)) div $rounding-factor"/>
 
125
                        </xsl:when>
 
126
                        <xsl:when test="contains($value, 'pt')">
 
127
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') * $point-in-mm)) div $rounding-factor"/>
 
128
                        </xsl:when>
 
129
                        <xsl:when test="contains($value, 'twip')">
 
130
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') * $twip-in-mm)) div $rounding-factor"/>
 
131
                        </xsl:when>
 
132
                        <xsl:when test="contains($value, 'dpt')">
 
133
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') * $didot-point-in-mm)) div $rounding-factor"/>
 
134
                        </xsl:when>
 
135
                        <xsl:when test="contains($value, 'pica')">
 
136
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') * $pica-in-mm)) div $rounding-factor"/>
 
137
                        </xsl:when>
 
138
                        <xsl:when test="contains($value, 'px')">
 
139
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') * $pixel-in-mm)) div $rounding-factor"/>
 
140
                        </xsl:when>
 
141
                        <xsl:otherwise>
 
142
                                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'mm'!</xsl:message>
 
143
                                <xsl:value-of select="$value"/>
 
144
                        </xsl:otherwise>
 
145
                </xsl:choose>
 
146
        </xsl:template>
 
147
        <!-- changing measure to cm -->
 
148
        <xsl:template name="convert2cm">
 
149
                <xsl:param name="value"/>
 
150
                <xsl:param name="rounding-factor" select="10000"/>
 
151
                <xsl:choose>
 
152
                        <xsl:when test="contains($value, 'mm')">
 
153
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $centimeter-in-mm)) div $rounding-factor"/>
 
154
                        </xsl:when>
 
155
                        <xsl:when test="contains($value, 'cm')">
 
156
                                <xsl:value-of select="substring-before($value, 'cm')"/>
 
157
                        </xsl:when>
 
158
                        <xsl:when test="contains($value, 'in')">
 
159
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $centimeter-in-mm * $inch-in-mm)) div $rounding-factor"/>
 
160
                        </xsl:when>
 
161
                        <xsl:when test="contains($value, 'pt')">
 
162
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $centimeter-in-mm * $point-in-mm)) div $rounding-factor"/>
 
163
                        </xsl:when>
 
164
                        <xsl:when test="contains($value, 'dpt')">
 
165
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $centimeter-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
 
166
                        </xsl:when>
 
167
                        <xsl:when test="contains($value, 'pica')">
 
168
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $centimeter-in-mm * $pica-in-mm)) div $rounding-factor"/>
 
169
                        </xsl:when>
 
170
                        <xsl:when test="contains($value, 'twip')">
 
171
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $centimeter-in-mm * $twip-in-mm)) div $rounding-factor"/>
 
172
                        </xsl:when>
 
173
                        <xsl:when test="contains($value, 'px')">
 
174
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $centimeter-in-mm * $pixel-in-mm)) div $rounding-factor"/>
 
175
                        </xsl:when>
 
176
                        <xsl:otherwise>
 
177
                                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'cm'!</xsl:message>
 
178
                                <xsl:value-of select="$value"/>
 
179
                        </xsl:otherwise>
 
180
                </xsl:choose>
 
181
        </xsl:template>
 
182
        <!-- changing measure to inch (cp. section comment) -->
 
183
        <xsl:template name="convert2in">
 
184
                <xsl:param name="value"/>
 
185
                <xsl:param name="rounding-factor" select="10000"/>
 
186
                <xsl:choose>
 
187
                        <xsl:when test="contains($value, 'mm')">
 
188
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $inch-in-mm)) div $rounding-factor"/>
 
189
                        </xsl:when>
 
190
                        <xsl:when test="contains($value, 'cm')">
 
191
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $inch-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
 
192
                        </xsl:when>
 
193
                        <xsl:when test="contains($value, 'in')">
 
194
                                <xsl:value-of select="substring-before($value, 'in')"/>
 
195
                        </xsl:when>
 
196
                        <xsl:when test="contains($value, 'pt')">
 
197
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $inch-in-mm * $point-in-mm)) div $rounding-factor"/>
 
198
                        </xsl:when>
 
199
                        <xsl:when test="contains($value, 'dpt')">
 
200
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $inch-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
 
201
                        </xsl:when>
 
202
                        <xsl:when test="contains($value, 'pica')">
 
203
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $inch-in-mm * $pica-in-mm)) div $rounding-factor"/>
 
204
                        </xsl:when>
 
205
                        <xsl:when test="contains($value, 'twip')">
 
206
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $inch-in-mm * $twip-in-mm)) div $rounding-factor"/>
 
207
                        </xsl:when>
 
208
                        <xsl:when test="contains($value, 'px')">
 
209
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $inch-in-mm * $pixel-in-mm)) div $rounding-factor"/>
 
210
                        </xsl:when>
 
211
                        <xsl:otherwise>
 
212
                                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'in'!</xsl:message>
 
213
                                <xsl:value-of select="$value"/>
 
214
                        </xsl:otherwise>
 
215
                </xsl:choose>
 
216
        </xsl:template>
 
217
        <!-- changing measure to dpt (cp. section comment) -->
 
218
        <xsl:template name="convert2dpt">
 
219
                <xsl:param name="value"/>
 
220
                <xsl:param name="rounding-factor" select="10000"/>
 
221
                <xsl:choose>
 
222
                        <xsl:when test="contains($value, 'mm')">
 
223
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $didot-point-in-mm)) div $rounding-factor"/>
 
224
                        </xsl:when>
 
225
                        <xsl:when test="contains($value, 'cm')">
 
226
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $didot-point-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
 
227
                        </xsl:when>
 
228
                        <xsl:when test="contains($value, 'in')">
 
229
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $didot-point-in-mm * $inch-in-mm)) div $rounding-factor"/>
 
230
                        </xsl:when>
 
231
                        <xsl:when test="contains($value, 'pt')">
 
232
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $didot-point-in-mm * $point-in-mm)) div $rounding-factor"/>
 
233
                        </xsl:when>
 
234
                        <xsl:when test="contains($value, 'dpt')">
 
235
                                <xsl:value-of select="substring-before($value, 'dpt')"/>
 
236
                        </xsl:when>
 
237
                        <xsl:when test="contains($value, 'pica')">
 
238
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $didot-point-in-mm * $pica-in-mm)) div $rounding-factor"/>
 
239
                        </xsl:when>
 
240
                        <xsl:when test="contains($value, 'twip')">
 
241
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $didot-point-in-mm * $twip-in-mm)) div $rounding-factor"/>
 
242
                        </xsl:when>
 
243
                        <xsl:when test="contains($value, 'px')">
 
244
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $didot-point-in-mm * $pixel-in-mm)) div $rounding-factor"/>
 
245
                        </xsl:when>
 
246
                        <xsl:otherwise>
 
247
                                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'dpt'!</xsl:message>
 
248
                                <xsl:value-of select="$value"/>
 
249
                        </xsl:otherwise>
 
250
                </xsl:choose>
 
251
        </xsl:template>
 
252
        <!-- changing measure to pica (cp. section comment) -->
 
253
        <xsl:template name="convert2pica">
 
254
                <xsl:param name="value"/>
 
255
                <xsl:param name="rounding-factor" select="10000"/>
 
256
                <xsl:choose>
 
257
                        <xsl:when test="contains($value, 'mm')">
 
258
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $pica-in-mm)) div $rounding-factor"/>
 
259
                        </xsl:when>
 
260
                        <xsl:when test="contains($value, 'cm')">
 
261
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $pica-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
 
262
                        </xsl:when>
 
263
                        <xsl:when test="contains($value, 'in')">
 
264
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $pica-in-mm * $inch-in-mm)) div $rounding-factor"/>
 
265
                        </xsl:when>
 
266
                        <xsl:when test="contains($value, 'pt')">
 
267
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $pica-in-mm * $point-in-mm)) div $rounding-factor"/>
 
268
                        </xsl:when>
 
269
                        <xsl:when test="contains($value, 'dpt')">
 
270
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $pica-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
 
271
                        </xsl:when>
 
272
                        <xsl:when test="contains($value, 'pica')">
 
273
                                <xsl:value-of select="substring-before($value, 'pica')"/>
 
274
                        </xsl:when>
 
275
                        <xsl:when test="contains($value, 'twip')">
 
276
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $pica-in-mm * $twip-in-mm)) div $rounding-factor"/>
 
277
                        </xsl:when>
 
278
                        <xsl:when test="contains($value, 'px')">
 
279
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $pica-in-mm * $pixel-in-mm)) div $rounding-factor"/>
 
280
                        </xsl:when>
 
281
                        <xsl:otherwise>
 
282
                                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'pica'!</xsl:message>
 
283
                                <xsl:value-of select="$value"/>
 
284
                        </xsl:otherwise>
 
285
                </xsl:choose>
 
286
        </xsl:template>
 
287
        <!-- changing measure to pt (cp. section comment) -->
 
288
        <xsl:template name="convert2pt">
 
289
                <xsl:param name="value"/>
 
290
                <xsl:param name="rounding-factor" select="10000"/>
 
291
                <xsl:choose>
 
292
                        <xsl:when test="contains($value, 'mm')">
 
293
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $point-in-mm)) div $rounding-factor"/>
 
294
                        </xsl:when>
 
295
                        <xsl:when test="contains($value, 'cm')">
 
296
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $point-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
 
297
                        </xsl:when>
 
298
                        <xsl:when test="contains($value, 'in')">
 
299
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $point-in-mm * $inch-in-mm)) div $rounding-factor"/>
 
300
                        </xsl:when>
 
301
                        <xsl:when test="contains($value, 'pt')">
 
302
                                <xsl:value-of select="substring-before($value, 'pt')"/>
 
303
                        </xsl:when>
 
304
                        <xsl:when test="contains($value, 'dpt')">
 
305
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $point-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
 
306
                        </xsl:when>
 
307
                        <xsl:when test="contains($value, 'pica')">
 
308
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $point-in-mm * $pica-in-mm)) div $rounding-factor"/>
 
309
                        </xsl:when>
 
310
                        <xsl:when test="contains($value, 'twip')">
 
311
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'twip') div $point-in-mm * $twip-in-mm)) div $rounding-factor"/>
 
312
                        </xsl:when>
 
313
                        <xsl:when test="contains($value, 'px')">
 
314
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $point-in-mm * $pixel-in-mm)) div $rounding-factor"/>
 
315
                        </xsl:when>
 
316
                        <xsl:otherwise>
 
317
                                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'pt'!</xsl:message>
 
318
                                <xsl:value-of select="$value"/>
 
319
                        </xsl:otherwise>
 
320
                </xsl:choose>
 
321
        </xsl:template>
 
322
        <!-- changing measure to twip (cp. section comment) -->
 
323
        <xsl:template name="convert2twip">
 
324
                <xsl:param name="value"/>
 
325
                <xsl:param name="rounding-factor" select="10000"/>
 
326
                <xsl:choose>
 
327
                        <xsl:when test="contains($value, 'mm')">
 
328
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'mm') div $twip-in-mm)) div $rounding-factor"/>
 
329
                        </xsl:when>
 
330
                        <xsl:when test="contains($value, 'cm')">
 
331
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'cm') div $twip-in-mm * $centimeter-in-mm)) div $rounding-factor"/>
 
332
                        </xsl:when>
 
333
                        <xsl:when test="contains($value, 'in')">
 
334
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'in') div $twip-in-mm * $inch-in-mm)) div $rounding-factor"/>
 
335
                        </xsl:when>
 
336
                        <xsl:when test="contains($value, 'pt')">
 
337
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pt') div $twip-in-mm * $point-in-mm)) div $rounding-factor"/>
 
338
                        </xsl:when>
 
339
                        <xsl:when test="contains($value, 'dpt')">
 
340
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'dpt') div $twip-in-mm * $didot-point-in-mm)) div $rounding-factor"/>
 
341
                        </xsl:when>
 
342
                        <xsl:when test="contains($value, 'pica')">
 
343
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'pica') div $twip-in-mm * $pica-in-mm)) div $rounding-factor"/>
 
344
                        </xsl:when>
 
345
                        <xsl:when test="contains($value, 'twip')">
 
346
                                <xsl:value-of select="substring-before($value, 'twip')"/>
 
347
                        </xsl:when>
 
348
                        <xsl:when test="contains($value, 'px')">
 
349
                                <xsl:value-of select="round($rounding-factor * number(substring-before($value, 'px') div $twip-in-mm * $pixel-in-mm)) div $rounding-factor"/>
 
350
                        </xsl:when>
 
351
                        <xsl:otherwise>
 
352
                                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'twip'!</xsl:message>
 
353
                                <xsl:value-of select="$value"/>
 
354
                        </xsl:otherwise>
 
355
                </xsl:choose>
 
356
        </xsl:template>
 
357
        <!-- changing measure to pixel by via parameter provided dpi (dots per inch) standard factor (cp. section comment) -->
 
358
        <xsl:template name="convert2px">
 
359
                <xsl:param name="value"/>
 
360
                <xsl:choose>
 
361
                        <xsl:when test="contains($value, 'mm')">
 
362
                                <xsl:value-of select="round(number(substring-before($value, 'mm')) div $pixel-in-mm)"/>
 
363
                        </xsl:when>
 
364
                        <xsl:when test="contains($value, 'cm')">
 
365
                                <xsl:value-of select="round(number(substring-before($value, 'cm')) div $pixel-in-mm * $centimeter-in-mm)"/>
 
366
                        </xsl:when>
 
367
                        <xsl:when test="contains($value, 'in')">
 
368
                                <xsl:value-of select="round(number(substring-before($value, 'in')) div $pixel-in-mm * $inch-in-mm)"/>
 
369
                        </xsl:when>
 
370
                        <xsl:when test="contains($value, 'pt')">
 
371
                                <xsl:value-of select="round(number(substring-before($value, 'pt')) div $pixel-in-mm * $point-in-mm)"/>
 
372
                        </xsl:when>
 
373
                        <xsl:when test="contains($value, 'dpt')">
 
374
                                <xsl:value-of select="round(number(substring-before($value, 'dpt')) div $pixel-in-mm * $didot-point-in-mm)"/>
 
375
                        </xsl:when>
 
376
                        <xsl:when test="contains($value, 'pica')">
 
377
                                <xsl:value-of select="round(number(substring-before($value, 'pica')) div $pixel-in-mm * $pica-in-mm)"/>
 
378
                        </xsl:when>
 
379
                        <xsl:when test="contains($value, 'twip')">
 
380
                                <xsl:value-of select="round(number(substring-before($value, 'twip')) div $pixel-in-mm * $twip-in-mm)"/>
 
381
                        </xsl:when>
 
382
                        <xsl:when test="contains($value, 'px')">
 
383
                                <xsl:value-of select="$value"/>
 
384
                        </xsl:when>
 
385
                        <xsl:otherwise>
 
386
                                <xsl:message>measure_conversion.xsl: Find no conversion for <xsl:value-of select="$value"/> to 'px'!</xsl:message>
 
387
                                <xsl:value-of select="$value"/>
 
388
                        </xsl:otherwise>
 
389
                </xsl:choose>
 
390
        </xsl:template>
 
391
</xsl:stylesheet>