Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / profiles / default / csv / to.xsl @ 187

History | View | Annotate | Download (3 kB)

1
<?xml version="1.0" encoding="UTF-8"?>
2

    
3
<xsl:stylesheet version="2.0"
4
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
6
	xmlns:tei="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="xs tei">
7

    
8
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
9
      <desc>
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: James Cummings </p>
43
         <p>Id: $Id: to.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
44
         <p>Copyright: 2010, TEI Consortium</p>
45
	<p>
46
		Usage:  saxon filename.xsl tei2csv.xsl 
47
		<ul>
48
		<li> This produces files named tableX.csv
49
		where X is the number of the table in the 
50
		document as a whole.</li>
51
		<li> All other content is discarded</li>
52
		<li> All output is in UTF-8, input-encoding is 
53
		based on XML declaration in the original file.
54
		</li>
55
		</ul>
56
	</p>
57
      </desc>
58
   </doc>
59
   <xsl:output omit-xml-declaration="yes"/>
60

    
61
  <xsl:param name="directory"></xsl:param>
62

    
63
   <xsl:template match="/">
64
     <xsl:for-each select="//tei:table">
65
       <xsl:variable name="tableNum">
66
	 <xsl:number level="any"/>
67
       </xsl:variable>
68
       <xsl:result-document href="{concat($directory,'table',$tableNum, '.csv')}"
69
			    encoding="UTF-8" method="text">
70
	 <xsl:for-each select="tei:row">
71
	   <xsl:for-each select="tei:cell">
72
	     <xsl:value-of select="concat('&quot;',normalize-space(.),'&quot;')"/>
73
	     <xsl:if test="following-sibling::tei:cell[1]">,</xsl:if>
74
	   </xsl:for-each>
75
	   <xsl:text>&#xa;</xsl:text>
76
	 </xsl:for-each>
77
       </xsl:result-document>
78
     </xsl:for-each>
79
   </xsl:template>
80
</xsl:stylesheet>