Last active
December 19, 2015 17:49
-
-
Save tonyahowe/5994135 to your computer and use it in GitHub Desktop.
Working XSLT for the file evelina.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0'?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xpath-default-namespace="http://www.tei-c.org/ns/1.0" version="2.0"> | |
<xsl:template match="TEI"> | |
<html> | |
<head> | |
<title>Evelina; or, The History of a Young Lady's Entrance Into the World</title> | |
<style type="text/css"> | |
body{ | |
font:13px georgia; | |
line-height:170%; | |
margin-top: 20px; | |
margin-left: 20%; | |
margin-right: 20%; | |
} | |
l { | |
font: 15px; arial; <!-- the xslt doesn't seem to be putting <l>s around the <l>s! --> | |
} | |
</style> | |
</head> | |
<body> | |
<xsl:apply-templates/> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template match="teiHeader"/> | |
<!-- keeps teiHeader from displaying --> | |
<xsl:template match="//div[@type='titlepage']"> | |
<center> | |
<h1> | |
<i> | |
<xsl:value-of select="head"/> | |
</i> | |
</h1> | |
<h2> By <xsl:value-of select="byline"/> | |
</h2> | |
<h3> | |
<p> | |
<xsl:value-of select="dateline"/> | |
</p> | |
</h3> | |
</center> | |
</xsl:template> | |
<xsl:template match="l"> | |
<!-- displays all <l>s --> | |
<l><xsl:apply-templates/> | |
</l> | |
</xsl:template> | |
<xsl:template match="//div[@type='inscription']"> | |
<h2> Inscription, <xsl:value-of select="salute"/> | |
</h2> | |
<xsl:apply-templates/> | |
</xsl:template> | |
<xsl:template match="l"> | |
<!-- displays all <l>s --> | |
<xsl:apply-templates/> | |
<br/> | |
</xsl:template> | |
<xsl:template match="//div[@type='preface']" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<h2> | |
<xsl:value-of select="head"/> | |
</h2> | |
<xsl:apply-templates/> | |
</xsl:template> | |
<xsl:template match="//div[@type='dedication']"> | |
<h2> Dedication, to <xsl:value-of select="salute"/> | |
</h2> | |
<xsl:apply-templates/> | |
</xsl:template> | |
<xsl:template match="//div[@type='letter']"> | |
<h3> | |
<xsl:value-of select="opener"/> | |
</h3> | |
<xsl:apply-templates/> | |
</xsl:template> | |
<xsl:template match="//div[@type='letter']"> | |
<h2> | |
<xsl:value-of select="head"/> | |
</h2> | |
<h3> | |
<xsl:value-of select="opener"/> | |
</h3> | |
<xsl:apply-templates/> | |
</xsl:template> | |
<xsl:template match="p"> | |
<p> | |
<xsl:apply-templates/> | |
</p> | |
</xsl:template> | |
<xsl:template match="//div/floatingText" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<blockquote> | |
<h2> | |
<xsl:value-of select="head"/> | |
</h2> | |
<h3> | |
<xsl:value-of select="opener"/> | |
</h3> | |
</blockquote> | |
<xsl:apply-templates/> | |
</xsl:template> | |
<xsl:template match="//div[@type='enclosedLetter']" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<blockquote> | |
<h2> | |
<xsl:value-of select="head"/> | |
</h2> | |
<h3> | |
<xsl:value-of select="opener"/> | |
</h3> | |
</blockquote> | |
<xsl:apply-templates/> | |
</xsl:template> | |
</xsl:stylesheet> |
Whoa, thanks Chriztian! Just learning, so this is a big, big help. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Couple of points:
match="//div"
-match="div"
works just the same (and looks better :-)<l>
s don't get copied because your template instructs the processor to "continue" (apply-templates)Note that you can match more than one type if the output is the same.
<p>
or<l>
) you can have a generic copy template do that, so you don't have to explicitly create it - just make sure to remove the existing p and l templates if you use this, e.g.:Hope that helps a bit...
/Chriztian