Tei2pml

From TEIWiki

Revision as of 09:05, 10 July 2007 by Piotr Banski (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>


<!--

  tei2pml.xsl
  
  This stylesheet is used in the Alex Catalogue of Electronic Texts.
  Through it TEI files are converted into PalmPilot eReader files. Once
  you run your TEI/XML through the stylesheet you must "compile" the
  output with something like MakeBook by the now defunct Peanut Press to
  actually create the eReader file.
  
  This file is distributed under the GNU Public License.
  
  Eric Lease Morgan (eric_morgan@infomotions.com)
  May 5, 2005

-->


<xsl:output method='text' />
<xsl:strip-space elements='*' />
<xsl:template match='TEI.2'>

<!-- title -->
<xsl:text>

</xsl:text>
<xsl:text>\c\b</xsl:text><xsl:value-of select='teiHeader/fileDesc/titleStmt/title' /><xsl:text>\b
\c
</xsl:text>
<xsl:text>\c</xsl:text><xsl:value-of select='normalize-space(/TEI.2/text/front/titlePage/byline)' /><xsl:text>
\c
</xsl:text>
<xsl:text>\c</xsl:text><xsl:value-of select='normalize-space(/TEI.2/text/front/titlePage/docImprint)' /><xsl:value-of select='normalize-space(/TEI.2/text/front/titlePage/imprimatur)' /><xsl:text>
\c
</xsl:text>
<xsl:text>\w="75%"</xsl:text>

<!-- cool table of contents -->
<xsl:if test='/TEI.2/text/body/div1'>
	<xsl:text>
\bTable of contents\b</xsl:text>
	<xsl:for-each select="/TEI.2/text/*/div1">
		<xsl:if test='./@type != "colophon"'>
			<xsl:text>
\q="#</xsl:text><xsl:value-of select='@id'/><xsl:text>"</xsl:text><xsl:value-of select='./head' /><xsl:text>\q</xsl:text>
		</xsl:if>
	</xsl:for-each>
</xsl:if>

<!-- do the heavy lifting -->
<xsl:apply-templates/>

</xsl:template>
	
	
<!-- division #0 (div) -->
<xsl:template match="div">
	<xsl:choose>
		<xsl:when test='./@type = "colophon"'>
			<xsl:text>\w="75%"</xsl:text>
			<xsl:text>
\b\x</xsl:text><xsl:value-of select='normalize-space(./head)' /><xsl:text>\x\b</xsl:text>
			<xsl:apply-templates />
		</xsl:when>
		<xsl:otherwise>
			<xsl:apply-templates />
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="div1">
<xsl:choose>
<xsl:when test='./@type = "colophon"'>
<xsl:text>\w="75%"</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>
\b\x\Q="</xsl:text><xsl:value-of select='@id'/><xsl:text>"</xsl:text><xsl:value-of select='normalize-space(./head)' /><xsl:text>\x\b</xsl:text><xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- line group (lg) -->
<xsl:template match="lg">
<xsl:text>
</xsl:text><xsl:apply-templates />
</xsl:template>

<!-- line (l) -->
<xsl:template match="l">
<xsl:if test='@rend = "indent"'>
<xsl:text>    </xsl:text>
</xsl:if>
<xsl:apply-templates /><xsl:text>
</xsl:text>
</xsl:template>

<!-- paragraph (p) -->
<xsl:template match="p">
<xsl:text>

</xsl:text><xsl:apply-templates />
</xsl:template>

<!-- figure -->
<xsl:template match='figure'>
<xsl:if test='@url = "http://infomotions.com/logo.gif"'>
<xsl:text>\c\m="logo.png"
\c
</xsl:text>
<xsl:text>\c</xsl:text><xsl:value-of select='./figDesc'/><xsl:text>
\c</xsl:text>
</xsl:if>
<xsl:apply-templates />
</xsl:template>

<!-- figure description -->
<xsl:template match='figDesc'>
<xsl:if test='../figure/@url = "http://infomotions.com/logo.gif"'>
</xsl:if>
</xsl:template>

<!-- do nothing templates -->

<!-- teiheader (do nothing) -->
<xsl:template match="teiHeader" />

<!-- teiheader (do nothing) -->
<xsl:template match="front/titlePage" />
	
<!-- head (head) -->
<xsl:template match="head" />

</xsl:stylesheet>
Personal tools