Difference between revisions of "Janus.xslt"
Jump to navigation
Jump to search
m (bug fix: remove duplicate templates) |
(fix obvious (and severe) bugs, thanks to Keith Handley) |
||
| Line 15: | Line 15: | ||
<!-- Written 2006-09-15 by Syd Bauman --> | <!-- Written 2006-09-15 by Syd Bauman --> | ||
| + | <!-- Updated 2014-12-25 per Keith Handley: fix obvious copy-and-paste errors --> | ||
<xsl:import href="Copy-All.xsl"/> | <xsl:import href="Copy-All.xsl"/> | ||
| Line 39: | Line 40: | ||
</xsl:element> | </xsl:element> | ||
<xsl:element name="abbr"> | <xsl:element name="abbr"> | ||
| − | <xsl:value-of select="@ | + | <xsl:value-of select="@abbr"/> |
</xsl:element> | </xsl:element> | ||
</xsl:element> | </xsl:element> | ||
| Line 63: | Line 64: | ||
</xsl:element> | </xsl:element> | ||
<xsl:element name="sic"> | <xsl:element name="sic"> | ||
| − | <xsl:value-of select="@ | + | <xsl:value-of select="@sic"/> |
</xsl:element> | </xsl:element> | ||
</xsl:element> | </xsl:element> | ||
| Line 87: | Line 88: | ||
</xsl:element> | </xsl:element> | ||
<xsl:element name="orig"> | <xsl:element name="orig"> | ||
| − | <xsl:value-of select="@ | + | <xsl:value-of select="@orig"/> |
</xsl:element> | </xsl:element> | ||
</xsl:element> | </xsl:element> | ||
</xsl:template> | </xsl:template> | ||
| − | </xsl:stylesheet></nowiki></pre> | + | </xsl:stylesheet> |
| + | </nowiki></pre> | ||
[[Category:P4toP5]] | [[Category:P4toP5]] | ||
[[Category:XSLT]] | [[Category:XSLT]] | ||
Latest revision as of 18:08, 25 December 2014
This stylesheet converts the so-called "janus" elements into proper P5 <choice>s. That is all.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- Tiny XSLT 1.0 stylesheet that reads in a TEI P4:2004 file (or -->
<!-- any other TEI P4-like file, really) and writes out the same file -->
<!-- with the "janus" elements (<abbr expan=>, <expan abbr=>; <sic corr=>, -->
<!-- <corr sic=>; <orig reg=>, <reg orig=>) converted into <choice> -->
<!-- elements. -->
<!-- Copyleft 2006 Syd Bauman and the Brown University Women Writers Project -->
<!-- The output of this stylesheet is not P5-comnpliant XML; it is just -->
<!-- the same P4 document with <choice> instead of the so-called janus tags. -->
<!-- Written 2006-09-15 by Syd Bauman -->
<!-- Updated 2014-12-25 per Keith Handley: fix obvious copy-and-paste errors -->
<xsl:import href="Copy-All.xsl"/>
<xsl:output method="xml" encoding="UTF-8" cdata-section-elements="eg"/>
<xsl:template match="abbr[@expan]">
<xsl:element name="choice">
<xsl:element name="abbr">
<xsl:apply-templates select="./@*[local-name()!='expan']"/>
<xsl:apply-templates select="./child::node()"/>
</xsl:element>
<xsl:element name="expan">
<xsl:value-of select="@expan"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="expan[@abbr]">
<xsl:element name="choice">
<xsl:element name="expan">
<xsl:apply-templates select="./@*[local-name()!='abbr']"/>
<xsl:apply-templates select="./child::node()"/>
</xsl:element>
<xsl:element name="abbr">
<xsl:value-of select="@abbr"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="sic[@corr]">
<xsl:element name="choice">
<xsl:element name="sic">
<xsl:apply-templates select="./@*[local-name()!='corr']"/>
<xsl:apply-templates select="./child::node()"/>
</xsl:element>
<xsl:element name="corr">
<xsl:value-of select="@corr"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="corr[@sic]">
<xsl:element name="choice">
<xsl:element name="corr">
<xsl:apply-templates select="./@*[local-name()!='sic']"/>
<xsl:apply-templates select="./child::node()"/>
</xsl:element>
<xsl:element name="sic">
<xsl:value-of select="@sic"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="orig[@reg]">
<xsl:element name="choice">
<xsl:element name="orig">
<xsl:apply-templates select="./@*[local-name()!='reg']"/>
<xsl:apply-templates select="./child::node()"/>
</xsl:element>
<xsl:element name="reg">
<xsl:value-of select="@reg"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="reg[@orig]">
<xsl:element name="choice">
<xsl:element name="reg">
<xsl:apply-templates select="./@*[local-name()!='orig']"/>
<xsl:apply-templates select="./child::node()"/>
</xsl:element>
<xsl:element name="orig">
<xsl:value-of select="@orig"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>