Mode:

Compact lists

Showing:

Documentation
Used by
References
Source
Main stylesheet to.xsl
Documentation

Description

This software is dual-licensed: 1. Distributed under a Creative Commons Attribution-ShareAlike 3.0 Unported License http://creativecommons.org/licenses/by-sa/3.0/ 2. http://www.opensource.org/licenses/BSD-2-Clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright holder or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

Author: James Cummings

Copyright: 2010, TEI Consortium

Usage: saxon filename.xsl tei2csv.xsl

  • This produces files named tableX.csv where X is the number of the table in the document as a whole.
  • All other content is discarded
  • All output is in UTF-8, input-encoding is based on XML declaration in the original file.

Stylesheet version 3.0
Template /
Namespace No namespace
Match /
Mode #default
References
Parameters
Variables
Import precedence 0
Source
<xsl:template match="/">
  <xsl:for-each select="//tei:table">
    <xsl:variable name="tableNum">
      <xsl:number level="any"/>
    </xsl:variable>
    <xsl:variable name="dest" select="concat($directory,$filePrefix,$tableNum, '.csv')"/>
    <xsl:message>Writing
      <xsl:value-of select="$dest"/>
    </xsl:message>
    <xsl:result-document href="{$dest}" encoding="UTF-8" method="text">
      <xsl:for-each select="tei:row">
        <xsl:for-each select="tei:cell">
          <xsl:value-of select="concat($dq,replace(normalize-space(.),$dq,$qdq),$dq)"/>
          <xsl:if test="following-sibling::tei:cell[1]">,</xsl:if>
        </xsl:for-each>
        <xsl:text>
</xsl:text>
      </xsl:for-each>
    </xsl:result-document>
  </xsl:for-each>
</xsl:template>
Stylesheet location to.xsl
Parameter filePrefix
Namespace No namespace
Used by
Template
Source
<xsl:param name="filePrefix">/table</xsl:param>
Stylesheet location to.xsl
Parameter directory
Namespace No namespace
Used by
Template
Source
<xsl:param name="directory">.</xsl:param>
Stylesheet location to.xsl
Variable dq
Namespace No namespace
Used by
Template
Source
<xsl:variable name="dq">"</xsl:variable>
Stylesheet location to.xsl
Variable qdq
Namespace No namespace
Used by
Template
Source
<xsl:variable name="qdq">""</xsl:variable>
Stylesheet location to.xsl
Output (default)
Namespace No namespace
Output properties
omit-xml-declaration
yes
Source
<xsl:output omit-xml-declaration="yes"/>
Stylesheet location to.xsl