Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / docx / utils / graphics / fixgraphics.xsl @ 187

History | View | Annotate | Download (3.9 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
3
                xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
4
                xmlns:teidocx="http://www.tei-c.org/ns/teidocx/1.0"
5
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6
                version="2.0">
7
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
8
      <desc>
9
         <p> TEI stylesheet dealing with elements from the core module. </p>
10
         <p>This software is dual-licensed:
11

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

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

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

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

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

    
30
This software is provided by the copyright holders and contributors
31
"as is" and any express or implied warranties, including, but not
32
limited to, the implied warranties of merchantability and fitness for
33
a particular purpose are disclaimed. In no event shall the copyright
34
holder or contributors be liable for any direct, indirect, incidental,
35
special, exemplary, or consequential damages (including, but not
36
limited to, procurement of substitute goods or services; loss of use,
37
data, or profits; or business interruption) however caused and on any
38
theory of liability, whether in contract, strict liability, or tort
39
(including negligence or otherwise) arising in any way out of the use
40
of this software, even if advised of the possibility of such damage.
41
</p>
42
         <p>Author: See AUTHORS</p>
43
         <p>Id: $Id: fixgraphics.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
44
         <p>Copyright: 2008, TEI Consortium</p>
45
      </desc>
46
   </doc>
47

    
48
  <xsl:output method="xml" indent="yes"/>
49
  <xsl:param name="DIR"/>
50
  <xsl:key name="W" match="tiff:ImageWidth" use="1"/>
51
  <xsl:key name="H" match="tiff:ImageLength" use="1"/>
52
  <xsl:template match="@*|text()|comment()|processing-instruction()">
53
      <xsl:copy-of select="."/>
54
  </xsl:template>
55
  
56
  
57
  <xsl:template match="*">
58
      <xsl:copy>
59
         <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
60
      </xsl:copy>
61
  </xsl:template>
62
  
63
  
64
  <xsl:template match="tei:graphic">
65
      <xsl:copy>
66
	        <xsl:variable name="newName">
67
	           <xsl:text>media/resource</xsl:text>
68
	           <xsl:number level="any"/>
69
	           <xsl:text>.</xsl:text>
70
	           <xsl:value-of select="tokenize(@url,'\.')[last()]"/>
71
	        </xsl:variable>
72
	        <xsl:attribute name="url">
73
	           <xsl:value-of select="$newName"/>
74
	        </xsl:attribute>
75
	        <xsl:copy-of select="@n"/>
76
	        <xsl:copy-of select="@height"/>
77
	        <xsl:copy-of select="@width"/>
78
	        <xsl:copy-of select="@scale"/>
79
		
80
	        <xsl:if test="doc-available(concat($DIR,'/',$newName,'.xmp'))">
81
	           <xsl:attribute name="tei:width">
82
	              <xsl:for-each select="document(concat($DIR,'/',$newName,'.xmp'),/)">
83
	                 <xsl:value-of select="(number(key('W',1)) div 72) * 9144"/>
84
	              </xsl:for-each>
85
	           </xsl:attribute>
86
	  
87
	           <xsl:attribute name="tei:height">
88
	              <xsl:for-each select="document(concat($DIR,'/',$newName,'.xmp'),/)">
89
	                 <xsl:value-of select="(number(key('H',1)) div 72) * 9144"/>
90
	              </xsl:for-each>
91
	           </xsl:attribute>
92
	        </xsl:if>
93
      </xsl:copy>
94
  </xsl:template>
95
</xsl:stylesheet>