Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / odt / fixgraphics.xsl @ 187

History | View | Annotate | Download (3.9 kB)

1 187 sjacqu01
<?xml version="1.0" encoding="utf-8"?>
2 187 sjacqu01
<xsl:stylesheet xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
3 187 sjacqu01
                xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
4 187 sjacqu01
                xmlns:teidocx="http://www.tei-c.org/ns/teidocx/1.0"
5 187 sjacqu01
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 187 sjacqu01
                version="2.0">
7 187 sjacqu01
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
8 187 sjacqu01
      <desc>
9 187 sjacqu01
         <p> TEI stylesheet dealing with elements from the core module. </p>
10 187 sjacqu01
         <p>This software is dual-licensed:
11 187 sjacqu01
12 187 sjacqu01
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
13 187 sjacqu01
Unported License http://creativecommons.org/licenses/by-sa/3.0/
14 187 sjacqu01
15 187 sjacqu01
2. http://www.opensource.org/licenses/BSD-2-Clause
16 187 sjacqu01
17 187 sjacqu01
All rights reserved.
18 187 sjacqu01
19 187 sjacqu01
Redistribution and use in source and binary forms, with or without
20 187 sjacqu01
modification, are permitted provided that the following conditions are
21 187 sjacqu01
met:
22 187 sjacqu01
23 187 sjacqu01
* Redistributions of source code must retain the above copyright
24 187 sjacqu01
notice, this list of conditions and the following disclaimer.
25 187 sjacqu01
26 187 sjacqu01
* Redistributions in binary form must reproduce the above copyright
27 187 sjacqu01
notice, this list of conditions and the following disclaimer in the
28 187 sjacqu01
documentation and/or other materials provided with the distribution.
29 187 sjacqu01
30 187 sjacqu01
This software is provided by the copyright holders and contributors
31 187 sjacqu01
"as is" and any express or implied warranties, including, but not
32 187 sjacqu01
limited to, the implied warranties of merchantability and fitness for
33 187 sjacqu01
a particular purpose are disclaimed. In no event shall the copyright
34 187 sjacqu01
holder or contributors be liable for any direct, indirect, incidental,
35 187 sjacqu01
special, exemplary, or consequential damages (including, but not
36 187 sjacqu01
limited to, procurement of substitute goods or services; loss of use,
37 187 sjacqu01
data, or profits; or business interruption) however caused and on any
38 187 sjacqu01
theory of liability, whether in contract, strict liability, or tort
39 187 sjacqu01
(including negligence or otherwise) arising in any way out of the use
40 187 sjacqu01
of this software, even if advised of the possibility of such damage.
41 187 sjacqu01
</p>
42 187 sjacqu01
         <p>Author: See AUTHORS</p>
43 187 sjacqu01
         <p>Id: $Id: fixgraphics.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
44 187 sjacqu01
         <p>Copyright: 2008, TEI Consortium</p>
45 187 sjacqu01
      </desc>
46 187 sjacqu01
   </doc>
47 187 sjacqu01
48 187 sjacqu01
  <xsl:output method="xml" indent="yes"/>
49 187 sjacqu01
  <xsl:param name="DIR"/>
50 187 sjacqu01
  <xsl:key name="W" match="tiff:ImageWidth" use="1"/>
51 187 sjacqu01
  <xsl:key name="H" match="tiff:ImageLength" use="1"/>
52 187 sjacqu01
  <xsl:template match="@*|text()|comment()|processing-instruction()">
53 187 sjacqu01
      <xsl:copy-of select="."/>
54 187 sjacqu01
  </xsl:template>
55 187 sjacqu01
56 187 sjacqu01
57 187 sjacqu01
  <xsl:template match="*">
58 187 sjacqu01
      <xsl:copy>
59 187 sjacqu01
         <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
60 187 sjacqu01
      </xsl:copy>
61 187 sjacqu01
  </xsl:template>
62 187 sjacqu01
63 187 sjacqu01
64 187 sjacqu01
  <xsl:template match="tei:graphic">
65 187 sjacqu01
      <xsl:copy>
66 187 sjacqu01
	        <xsl:variable name="newName">
67 187 sjacqu01
	           <xsl:text>Pictures/resource</xsl:text>
68 187 sjacqu01
	           <xsl:number level="any"/>
69 187 sjacqu01
	           <xsl:text>.</xsl:text>
70 187 sjacqu01
	           <xsl:value-of select="tokenize(@url,'\.')[last()]"/>
71 187 sjacqu01
	        </xsl:variable>
72 187 sjacqu01
	        <xsl:attribute name="url">
73 187 sjacqu01
	           <xsl:value-of select="$newName"/>
74 187 sjacqu01
	        </xsl:attribute>
75 187 sjacqu01
	        <xsl:copy-of select="@n"/>
76 187 sjacqu01
	        <xsl:copy-of select="@height"/>
77 187 sjacqu01
	        <xsl:copy-of select="@width"/>
78 187 sjacqu01
	        <xsl:copy-of select="@scale"/>
79 187 sjacqu01
80 187 sjacqu01
	        <xsl:if test="doc-available(concat($DIR,'/',$newName,'.xmp'))">
81 187 sjacqu01
	           <xsl:attribute name="tei:width">
82 187 sjacqu01
	              <xsl:for-each select="document(concat($DIR,'/',$newName,'.xmp'),/)">
83 187 sjacqu01
	                 <xsl:value-of select="(number(key('W',1)) div 72) * 9144"/>
84 187 sjacqu01
	              </xsl:for-each>
85 187 sjacqu01
	           </xsl:attribute>
86 187 sjacqu01
87 187 sjacqu01
	           <xsl:attribute name="tei:height">
88 187 sjacqu01
	              <xsl:for-each select="document(concat($DIR,'/',$newName,'.xmp'),/)">
89 187 sjacqu01
	                 <xsl:value-of select="(number(key('H',1)) div 72) * 9144"/>
90 187 sjacqu01
	              </xsl:for-each>
91 187 sjacqu01
	           </xsl:attribute>
92 187 sjacqu01
	        </xsl:if>
93 187 sjacqu01
      </xsl:copy>
94 187 sjacqu01
  </xsl:template>
95 187 sjacqu01
</xsl:stylesheet>