Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / txt / tei-to-text.xsl @ 187

History | View | Annotate | Download (3.7 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet 
3
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
4
    xpath-default-namespace="http://www.tei-c.org/ns/1.0"
5
    xmlns:tei="http://www.tei-c.org/ns/1.0"
6
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7
    version="2.0">
8

    
9
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
10
      <desc>
11

    
12
         <p>This software is dual-licensed:
13

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

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

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

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

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

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

    
50
   <xsl:output method="text"/>
51
   <xsl:param name="makeCSV">false</xsl:param>
52
   <xsl:variable name="q">"</xsl:variable>
53

    
54
   <xsl:template match="/">
55
     <xsl:apply-templates select="tei:preflight(*)"/>
56
   </xsl:template>
57

    
58
   <xsl:template match="teiHeader"/>
59

    
60
   <xsl:template match="figDesc"/>
61

    
62
   <xsl:template match="gap/desc"/>
63

    
64
   <xsl:template match="choice">
65
     <xsl:apply-templates select="*[1]"/>
66
   </xsl:template>
67

    
68
   <xsl:template match="speaker"/>
69

    
70
   <xsl:template match="facsimile"/>
71

    
72
   <!-- for when we need some context -->
73
   <xsl:template match="text()">
74
     <xsl:choose>
75
       <xsl:when test="normalize-space()=''"/>
76
       <xsl:when test="$makeCSV='true'">
77
	 <xsl:text>"</xsl:text>
78
	 <xsl:value-of select="replace(normalize-space(),'$q','$q$q')"/>
79
	 <xsl:text>","</xsl:text>
80
	 <xsl:for-each select="ancestor::*">
81
	   <xsl:value-of select="name()"/>
82
	   <xsl:text>[</xsl:text>
83
	   <xsl:number/>
84
	   <xsl:text>]/</xsl:text>
85
	 </xsl:for-each>
86
	 <xsl:text>"&#10;</xsl:text>
87
       </xsl:when>
88
       <xsl:otherwise>
89
	 <xsl:value-of select="normalize-space()"/>
90
	 <xsl:text>&#10;</xsl:text>
91
       </xsl:otherwise>
92
       </xsl:choose>
93
   </xsl:template>
94

    
95
   
96
   <xsl:function name="tei:preflight" as="element()+">
97
     <xsl:param name="n" as="element()"/>
98
     <xsl:apply-templates select="$n" mode="preflight"/>
99
   </xsl:function>
100
   
101
   <xsl:template match="@*|text()" mode="preflight">
102
     <xsl:copy-of select="."/>
103
   </xsl:template>
104
   
105
   <xsl:template match="lb|pb" mode="preflight"/>
106

    
107
   <xsl:template match="*" mode="preflight">
108
     <xsl:copy>
109
       <xsl:apply-templates select="@*|*|text()" mode="preflight"/>
110
     </xsl:copy>
111
   </xsl:template>
112
   
113
</xsl:stylesheet>