Tei2html

drondrontroc This XSLT file will convert a TEI 4 file to .html file intended for the Alex Catalogue of Electronic Texts. It is pretty much a plain o' HTML file that could be printed for viewed by the most basic of browsers. The output is suppose to about as Plain Jane as possible.

This file is distributed under the GNU Public License. Eric Lease Morgan (eric_morgan@infomotions.com) May 5, 2005

 

        /        </xsl:text> <xsl:value-of select="teiHeader/fileDesc/titleStmt/author/dateRange"/> <xsl:comment>Dublin Core elements</xsl:comment>

 <xsl:if test='./@type = "main"'> <xsl:attribute name='name'>title</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='.' /></xsl:attribute> </xsl:if> </xsl:for-each> <xsl:attribute name='name'>creator</xsl:attribute>  <xsl:if test='./@type = "main"'> <xsl:attribute name='content'><xsl:value-of select='.' /></xsl:attribute> </xsl:if> </xsl:for-each>  <xsl:attribute name='name'>subject</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='normalize-space(.)' /></xsl:attribute> </xsl:for-each>  <xsl:if test='./@type = "description"'> <xsl:attribute name='name'>description</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='.' /></xsl:attribute> </xsl:if> </xsl:for-each> <xsl:attribute name='name'>publisher</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='normalize-space(teiHeader/fileDesc/publicationStmt/publisher)' /></xsl:attribute>  <xsl:if test='./@type = "contributor"'> <xsl:attribute name='name'>contributor</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='.' /></xsl:attribute> </xsl:if> </xsl:for-each>

<xsl:attribute name='name'>date</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='normalize-space(teiHeader/profileDesc/creation/date)' /></xsl:attribute> <xsl:attribute name='name'>type</xsl:attribute> <xsl:attribute name='content'>Text</xsl:attribute> <xsl:attribute name='name'>format</xsl:attribute> <xsl:attribute name='content'>text/html</xsl:attribute> <xsl:attribute name='name'>identifier</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='normalize-space(teiHeader/fileDesc/publicationStmt/idno)' /></xsl:attribute> <xsl:attribute name='name'>source</xsl:attribute> <xsl:attribute name='content'> <xsl:value-of select='normalize-space(.)'/></xsl:for-each> </xsl:attribute> <xsl:attribute name='name'>language</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='normalize-space(teiHeader/profileDesc/langUsage/language)' /></xsl:attribute> <xsl:attribute name='name'>relation</xsl:attribute> <xsl:attribute name='content'>http://infomotions.com/alex/</xsl:attribute> <xsl:attribute name='name'>rights</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='normalize-space(teiHeader/fileDesc/publicationStmt/availability/p)' /></xsl:attribute> <xsl:comment>Alex Catalogue metadata elements</xsl:comment>

<xsl:attribute name='name'>sort_creator</xsl:attribute>  <xsl:if test='./@type = "sort"'> <xsl:attribute name='content'><xsl:value-of select='.' /></xsl:attribute> </xsl:if> </xsl:for-each> <xsl:attribute name='name'>sort_title</xsl:attribute>  <xsl:if test='./@type = "sort"'> <xsl:attribute name='content'><xsl:value-of select='.' /></xsl:attribute> </xsl:if> </xsl:for-each> <xsl:attribute name='name'>brief</xsl:attribute> <xsl:attribute name='content'>  <xsl:if test='./@type = "main"'> <xsl:value-of select='.' /> </xsl:if> </xsl:for-each>  / </xsl:text>  <xsl:if test='./@type = "main"'> <xsl:value-of select='.' /> </xsl:if> </xsl:for-each>  </xsl:text> <xsl:value-of select="teiHeader/fileDesc/titleStmt/author/dateRange"/>

</xsl:attribute> <xsl:attribute name='name'>sort_date</xsl:attribute> <xsl:attribute name='content'><xsl:value-of select='normalize-space(teiHeader/profileDesc/creation/date/@value)' /></xsl:attribute> <style type='text/css'>h1, h2, h3, h4, h5, h6 { font-family : sans-serif; } p.fiction { margin-top: 0em; margin-bottom: 0em;} <body style='margin:5%;'> <h1 style='text-align:center'><xsl:value-of select='teiHeader/fileDesc/titleStmt/title' /> <p style='text-align:center'><xsl:value-of select='/TEI.2/text/front/titlePage/byline' /> <p style='text-align:center'><xsl:value-of select='/TEI.2/text/front/titlePage/docImprint' /><xsl:value-of select='/TEI.2/text/front/titlePage/imprimatur' />

<xsl:if test='/TEI.2/text/body/div1'> Table of contents  <xsl:if test='./@type != "colophon"'> <a><xsl:attribute name="href">#<xsl:value-of select='./@id' /></xsl:attribute><xsl:value-of select='./head' /></a>

</xsl:if> </xsl:for-each> </xsl:if> <xsl:apply-templates/> </xsl:template> <xsl:template match="div"> <xsl:choose> <xsl:when test='./@type = "colophon"'> <xsl:value-of select='./head' /> </xsl:when> </xsl:choose> <xsl:apply-templates /> </xsl:template>

<xsl:template match="div1"> <xsl:choose> <xsl:when test='./@type = "colophon"'> </xsl:when> </xsl:choose> <a><xsl:attribute name="name"><xsl:value-of select='./@id' /></xsl:attribute><xsl:value-of select='./head' /></a> <xsl:apply-templates /> </xsl:template>

<xsl:template match="div2"> <xsl:value-of select='./@type' /> </xsl:text><xsl:value-of select='./@n' />. </xsl:text><xsl:value-of select='./head' /> <xsl:apply-templates /> </xsl:template>

<xsl:template match="div3"> <xsl:value-of select='./@type' /><xsl:text> </xsl:text><xsl:value-of select='./@n' /><xsl:text>. </xsl:text><xsl:value-of select='./head' /> <xsl:apply-templates /> </xsl:template>

<xsl:template match="div4"> <xsl:value-of select='./@type' /><xsl:text> </xsl:text><xsl:value-of select='./@n' /><xsl:text>. </xsl:text><xsl:value-of select='./head' /> <xsl:apply-templates /> </xsl:template>

<xsl:template match="div5"> <xsl:value-of select='./@type' /><xsl:text> </xsl:text><xsl:value-of select='./@n' /><xsl:text>. </xsl:text><xsl:value-of select='./head' /> <xsl:apply-templates /> </xsl:template>

<xsl:template match="figure"> <xsl:attribute name='src'><xsl:value-of select='./@url' /></xsl:attribute> <xsl:choose> <xsl:when test='./figDesc'> <xsl:attribute name='alt'><xsl:value-of select='normalize-space(./figDesc)' /></xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:attribute name='alt'><xsl:value-of select='./@url' /></xsl:attribute> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test='./@rend = "top"'> <xsl:attribute name='align'><xsl:value-of select='./@rend' /></xsl:attribute> </xsl:when> <xsl:when test='./@rend = "middle"'> <xsl:attribute name='align'><xsl:value-of select='./@rend' /></xsl:attribute> </xsl:when> <xsl:when test='./@rend = "bottom"'> <xsl:attribute name='align'><xsl:value-of select='./@rend' /></xsl:attribute> </xsl:when> <xsl:when test='./@rend = "left"'> <xsl:attribute name='align'><xsl:value-of select='./@rend' /></xsl:attribute> </xsl:when> <xsl:when test='./@rend = "right"'> <xsl:attribute name='align'><xsl:value-of select='./@rend' /></xsl:attribute> </xsl:when> <xsl:otherwise /> </xsl:choose> <xsl:apply-templates/> </xsl:template>

<xsl:template match='figDesc'> <xsl:apply-templates/> </xsl:template> <xsl:template match='lb'> <xsl:apply-templates /> </xsl:template>

<xsl:template match="p"> <xsl:choose> <xsl:when test='./@rend = "right"'> <p style='text-align:right'><xsl:apply-templates /> </xsl:when> <xsl:when test='./@rend = "center"'> <p style='text-align:center'><xsl:apply-templates /> </xsl:when> <xsl:when test='./@rend = "fiction"'> <p class='fiction'><xsl:text>&#160;&#160;&#160;&#160;</xsl:text><xsl:apply-templates /> </xsl:when> <xsl:when test='./@rend = "pre"'> <xsl:apply-templates /> </xsl:when> <xsl:otherwise> <xsl:apply-templates /> </xsl:otherwise> </xsl:choose> </xsl:template>

<xsl:template match="quote"> "<xsl:apply-templates />" </xsl:template>

<xsl:template match="lg"> <xsl:apply-templates /> </xsl:template>

<xsl:template match="l"> <xsl:if test='@rend = "indent"'> <xsl:text>&#160;&#160;&#160;&#160;</xsl:text> </xsl:if> <xsl:apply-templates />

</xsl:template>

<xsl:template match="xref"> <a><xsl:attribute name='href'><xsl:value-of select='./@url' /></xsl:attribute><xsl:apply-templates /></a> </xsl:template>

<xsl:template match="table"> <xsl:choose> <xsl:when test='./@rend = "left"'> </xsl:when> <xsl:when test='./@rend = "right"'> </xsl:when> <xsl:when test='./@rend = "center"'> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </xsl:template>

<xsl:template match="row"> <xsl:choose> <xsl:when test='./@rend = "left"'> <tr align='left' valign='top'><xsl:apply-templates /> </xsl:when> <xsl:when test='./@rend = "right"'> <tr align='right' valign='top'><xsl:apply-templates /> </xsl:when> <xsl:when test='./@rend = "center"'> <tr align='center' valign='top'><xsl:apply-templates /> </xsl:when> <xsl:when test='./@rend = "justify"'> <tr align='justify' valign='top'><xsl:apply-templates /> </xsl:when> <xsl:otherwise> <tr valign='top'><xsl:apply-templates /> </xsl:otherwise> </xsl:choose> </xsl:template>

<xsl:template match="cell"> <xsl:choose> <xsl:when test='./@rend = "left"'> <td align='left'><xsl:attribute name='colspan'><xsl:value-of select='@cols' /></xsl:attribute><xsl:apply-templates /> </xsl:when> <xsl:when test='./@rend = "right"'> <td align='right'><xsl:attribute name='colspan'><xsl:value-of select='@cols' /></xsl:attribute><xsl:apply-templates /> </xsl:when> <xsl:when test='./@rend = "center"'> <td align='center'><xsl:attribute name='colspan'><xsl:value-of select='@cols' /></xsl:attribute><xsl:apply-templates /> </xsl:when> <xsl:when test='./@rend = "justify"'> <td align='justify'><xsl:attribute name='colspan'><xsl:value-of select='@cols' /></xsl:attribute><xsl:apply-templates /> </xsl:when> <xsl:otherwise> <xsl:attribute name='colspan'><xsl:value-of select='@cols' /></xsl:attribute><xsl:apply-templates /> </xsl:otherwise> </xsl:choose> </xsl:template>

<xsl:template match="list[@type='gloss']"> <dl><xsl:apply-templates/></dl> </xsl:template> <xsl:template match="list[@type='ordered']"> <ol><xsl:apply-templates/></ol> </xsl:template> <xsl:template match="list[@type='bulleted']"> <ul><xsl:apply-templates/></ul> </xsl:template> <xsl:template match="list[@type='simple']"> <ul style='list-style-type: none'><xsl:apply-templates/></ul> </xsl:template> <xsl:template match="label[parent::list[@type='gloss']]"> <dt><xsl:apply-templates/></dt> </xsl:template> <xsl:template match="item[parent::list[@type='gloss']]"> <dd><xsl:apply-templates/></dd> </xsl:template> <xsl:template match="item[parent::list[@type='bulleted']]"> <li><xsl:apply-templates/></li> </xsl:template> <xsl:template match="item[parent::list[@type='simple']]"> <li><xsl:apply-templates/></li> </xsl:template> <xsl:template match="item[parent::list[@type='ordered']]"> <li><xsl:apply-templates/></li> </xsl:template>

<xsl:template match="teiHeader" /> <xsl:template match="front/titlePage" /> <xsl:template match="head" />

</xsl:stylesheet>