Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / tools / makegraphicsanttask.xsl @ 187

History | View | Annotate | Download (5.3 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:tei="http://www.tei-c.org/ns/1.0"
3
		xmlns:teix="http://www.tei-c.org/ns/Examples"
4
		xmlns:smil="http://www.w3.org/ns/SMIL"
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 to get list of graphics files and make an
10
	 ant task to copy them</p>
11
         <p>This software is dual-licensed:
12

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

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

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

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

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

    
31
This software is provided by the copyright holders and contributors
32
"as is" and any express or implied warranties, including, but not
33
limited to, the implied warranties of merchantability and fitness for
34
a particular purpose are disclaimed. In no event shall the copyright
35
holder or contributors be liable for any direct, indirect, incidental,
36
special, exemplary, or consequential damages (including, but not
37
limited to, procurement of substitute goods or services; loss of use,
38
data, or profits; or business interruption) however caused and on any
39
theory of liability, whether in contract, strict liability, or tort
40
(including negligence or otherwise) arising in any way out of the use
41
of this software, even if advised of the possibility of such damage.
42
</p>
43
         <p>Author: See AUTHORS</p>
44
         <p>Id: $Id: makegraphicsanttask.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
45
         <p>Copyright: 2008, TEI Consortium</p>
46
      </desc>
47
   </doc>
48
   <xsl:key name="G" match="tei:graphic[not(ancestor::teix:egXML)]"  use="1"/>
49
   <xsl:key name="PB" match="tei:pb[@facs and not(@rend='none')]" use="1"/>
50
   <xsl:key name="Timeline" match="tei:timeline" use="1"/>
51
   <xsl:param name="mediaoverlay">false</xsl:param>
52
   <xsl:param name="filePerPage">false</xsl:param>
53
   <xsl:param name="inputDir">.</xsl:param>
54
   <xsl:param name="mediaDir">word/media</xsl:param>
55
   <xsl:template match="/">
56
     <project xmlns="" basedir="." default="dist" name="imagecopy">
57
       <target name="dist">
58
	 <xsl:if test="key('PB',1) or key('G',1)">
59
	   <mkdir>
60
	     <xsl:attribute name="dir">
61
	       <xsl:text>${outputTempDir}/</xsl:text>
62
	       <xsl:value-of select="$mediaDir"/>
63
	     </xsl:attribute>
64
	   </mkdir>
65
	 </xsl:if>
66
	 <xsl:if test="$mediaoverlay='true' and key('Timeline',1)">
67
	   <xsl:for-each select="key('Timeline',1)">
68
	     <xsl:variable name="target">
69
	       <xsl:text>${outputTempDir}/</xsl:text>
70
	       <xsl:value-of select="$mediaDir"/>
71
	       <xsl:text>/audio</xsl:text>
72
	       <xsl:number level="any"/>
73
	       <xsl:text>.</xsl:text>
74
	       <xsl:value-of select="tokenize(@corresp,'\.')[last()]"/>
75
	     </xsl:variable>
76
	     <copy toFile="{$target}" file="{$inputDir}/{@corresp}"/>
77
	   </xsl:for-each>
78
	 </xsl:if>
79
	 <xsl:for-each select="key('PB',1)">
80
	   <xsl:variable name="F">
81
	     <xsl:choose>
82
	       <xsl:when test="starts-with(@facs,'#')">
83
		 <xsl:for-each select="id(substring(@facs,2))">
84
		   <xsl:value-of select="tei:graphic[1]/@url"/>
85
		 </xsl:for-each>
86
	       </xsl:when>
87
	       <xsl:otherwise>
88
		 <xsl:value-of select="@facs"/>
89
	       </xsl:otherwise>
90
	     </xsl:choose>
91
	   </xsl:variable>
92
	   <xsl:variable name="target">
93
	     <xsl:text>${outputTempDir}/</xsl:text>
94
	     <xsl:value-of select="$mediaDir"/>
95
	     <xsl:text>/pageimage</xsl:text>
96
	     <xsl:number level="any"/>
97
	     <xsl:text>.</xsl:text>
98
	     <xsl:value-of select="tokenize($F,'\.')[last()]"/>
99
	   </xsl:variable>
100
	   <xsl:choose>
101
	     <xsl:when test="starts-with($F,'http')">
102
	       <get src="{@url}" dest="{$target}"/>
103
	     </xsl:when>
104
	     <xsl:when test="starts-with($F,'/')">
105
	       <copy toFile="{$target}" file="{@url}"/>
106
	     </xsl:when>
107
	     <xsl:otherwise>
108
	       <copy toFile="{$target}" file="{$inputDir}/{$F}"/>
109
	     </xsl:otherwise>
110
	   </xsl:choose>
111
	 </xsl:for-each>
112

    
113
	 <xsl:for-each select="key('G',1)">
114
	   <xsl:variable name="F">
115
	     <xsl:value-of select="@url"/>
116
	   </xsl:variable>
117
	   <xsl:variable name="target">
118
	     <xsl:text>${outputTempDir}/</xsl:text>
119
	     <xsl:value-of select="$mediaDir"/>
120
	     <xsl:text>/resource</xsl:text>
121
	     <xsl:number level="any"/>
122
	     <xsl:text>.</xsl:text>
123
	     <xsl:value-of select="tokenize($F,'\.')[last()]"/>
124
	   </xsl:variable>
125
	   <xsl:choose>
126
	     <xsl:when test="starts-with($F,'http')">
127
	       <get src="{@url}" dest="{$target}"/>
128
	     </xsl:when>
129
	     <xsl:when test="starts-with($F,'/')">
130
	       <copy toFile="{$target}" file="{@url}"/>
131
	     </xsl:when>
132
	     <xsl:otherwise>
133
	       <copy toFile="{$target}" file="{$inputDir}/{@url}"/>
134
	     </xsl:otherwise>
135
	   </xsl:choose>
136
	 </xsl:for-each>
137
       </target>
138
     </project>
139
 </xsl:template>
140
   
141
 </xsl:stylesheet>