Bibl2struct.xslt

Summary
Transforms TEI s into bibliographies. Ignores all other content. Produces a .

Required Input
This document will take any XML file, not just TEI XML, and processes all complete bibliographies into equivalent .

The transform differentiates five major cases from the (non)-existence of s of certain @level (a,j,m,s). The level in parens, e.g. (a) means 'level a or without/blank level'.
 * has (a)+m+s titles ==> excerpt from work in series
 * has  (m)+s titles ==> work in series
 * has  (a)+j titles ==> journal article
 * has  (a)+m titles ==> excerpt from monograph
 * has    (m) titles ==> monograph

When an element contains @corresp the text is taken from that id. When the author is missing and has an id, then we look for the id in s and, when found, for authors therein. When the document contains a , we build that bibl and process it like the others.

Expected Output
a 

Known Restrictions or Problems
See TODO in the stylesheet.

Please add any comments to the 'discussion' tab. For payed support, please mail the author (address within stylesheet).

Stylesheet






 href="eb-bib.css" type="text/css"    

 </xsl:template> </xsl:template> </xsl:template> </xsl:template> </xsl:template> </xsl:template> </xsl:template> </xsl:template> </xsl:template> </xsl:template>







 <xsl:variable name='joint'> <xsl:call-template name='chomp-targets-recursively'> <xsl:with-param name='idstr'> <xsl:value-of select='@targets' /> </xsl:with-param> </xsl:call-template> </xsl:variable> <xsl:apply-templates select='exsl:node-set($joint)//bibl' /> </xsl:template>

 <xsl:param name='idstr' /> <xsl:variable name="first"> <xsl:variable name="first0" select="substring-before($idstr,' ')"/> <xsl:choose> <xsl:when test="$first0"> <xsl:copy-of select="$first0"/> </xsl:when> <xsl:otherwise> <xsl:copy-of select="$idstr"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:if test="string-length($first)"> <xsl:call-template name='chomp-targets-recursively'> <xsl:with-param name="idstr"> <xsl:value-of select="substring-after($idstr,' ')"/> </xsl:with-param> </xsl:call-template> <xsl:copy-of select='//*[@id=$first]' /> </xsl:if> </xsl:template>

 <biblStruct> <xsl:choose> <xsl:when test='author'> <xsl:apply-templates select='author' /> </xsl:when> <xsl:otherwise> <xsl:call-template name='authors' /> </xsl:otherwise> </xsl:choose> <xsl:apply-templates select='title[(@level="a" or @level="" or not(@level))]' /> <xsl:apply-templates select='editor' /> <xsl:apply-templates select='title[@level="m"]' /> <xsl:apply-templates select='editor' /> <xsl:apply-templates select='title[@level="s"]' /> <xsl:if test='date|publisher|pubPlace|biblScope'> <xsl:apply-templates select='publisher' /> <xsl:apply-templates select='pubPlace' /> <xsl:apply-templates select='edition' /> <xsl:apply-templates select='date' /> <xsl:apply-templates select='biblScope' /> </xsl:if> <xsl:apply-templates select='note' /> </biblStruct> </xsl:template>

<xsl:template match='bibl[not(title[@level="a"]) and (title[@level="m"] or title[@level=""] or title[not(@level)]) and title[@level="s"]]'> <biblStruct> <xsl:choose> <xsl:when test='author'> <xsl:apply-templates select='author' /> </xsl:when> <xsl:otherwise> <xsl:call-template name='authors' /> </xsl:otherwise> </xsl:choose> <xsl:apply-templates select='title[@level="m" or @level="" or not(@level)]' /> <xsl:if test='date|publisher|pubPlace|biblScope'> <xsl:apply-templates select='publisher' /> <xsl:apply-templates select='pubPlace' /> <xsl:apply-templates select='edition' /> <xsl:apply-templates select='date' /> <xsl:apply-templates select='biblScope' /> </xsl:if> <xsl:apply-templates select='editor' /> <xsl:apply-templates select='title[@level="s"]' /> <xsl:apply-templates select='note' /> </biblStruct> </xsl:template>

<xsl:template match='bibl[title[not(@level) or @level="a"] and title[@level="j"]]'> <biblStruct> <xsl:choose> <xsl:when test='author'> <xsl:apply-templates select='author' /> </xsl:when> <xsl:otherwise> <xsl:call-template name='authors' /> </xsl:otherwise> </xsl:choose> <xsl:apply-templates select='title[not(@level) or @level="a"]' /> <xsl:apply-templates select='title[@level="j"]' /> <xsl:if test='date|publisher|pubPlace|biblScope'> <xsl:apply-templates select='publisher' /> <xsl:apply-templates select='pubPlace' /> <xsl:apply-templates select='edition' /> <xsl:apply-templates select='date' /> <xsl:apply-templates select='biblScope' /> </xsl:if> <xsl:apply-templates select='editor' /> <xsl:apply-templates select='note' /> </biblStruct> </xsl:template>

<xsl:template match='bibl[title[not(@level) or @level="a"] and title[@level="m"]]'> <biblStruct> <xsl:choose> <xsl:when test='author'> <xsl:apply-templates select='author' /> </xsl:when> <xsl:otherwise> <xsl:call-template name='authors' /> </xsl:otherwise> </xsl:choose> <xsl:apply-templates select='title[not(@level) or @level="a"]' /> <xsl:apply-templates select='editor' /> <xsl:apply-templates select='title[@level="m"]' /> <xsl:if test='date|publisher|pubPlace|biblScope'> <xsl:apply-templates select='publisher' /> <xsl:apply-templates select='pubPlace' /> <xsl:apply-templates select='edition' /> <xsl:apply-templates select='date' /> <xsl:apply-templates select='biblScope' /> </xsl:if> <xsl:apply-templates select='note' /> </biblStruct> </xsl:template>

<xsl:template match='bibl[(not(title[@level="a"]) and not(title[@level="j"]) and not(title[@level="s"])) and ((title[@level="m"] and not(title[not(@level)])) or (not(title[@level="m"]) and title[not(@level)]))]'> <biblStruct> <xsl:choose> <xsl:when test='author'> <xsl:apply-templates select='author' /> </xsl:when> <xsl:otherwise> <xsl:call-template name='authors' /> </xsl:otherwise> </xsl:choose> <xsl:apply-templates select='title' /> <xsl:if test='date|publisher|pubPlace|biblScope'> <xsl:apply-templates select='publisher' /> <xsl:apply-templates select='pubPlace' /> <xsl:apply-templates select='edition' /> <xsl:apply-templates select='date' /> <xsl:apply-templates select='biblScope' /> </xsl:if> <xsl:apply-templates select='note' /> </biblStruct> </xsl:template>

<xsl:template name='authors'> <xsl:if test='not(@id)'> <xsl:text>ERROR: bibl has neither author nor id! </xsl:text> </xsl:if> <xsl:if test='@id'> <xsl:variable name='ti'> <xsl:value-of select='@id' /> </xsl:variable> <xsl:for-each select='//link'> <xsl:if test='contains(@targets,$ti)'> <xsl:call-template name='recursively-apply-first-of'> <xsl:with-param name='idstr'> <xsl:value-of select='@targets' /> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:for-each> </xsl:if> </xsl:template>

<xsl:template name='recursively-apply-first-of'> <xsl:param name='idstr' /> <xsl:variable name="first"> <xsl:variable name="first0" select="substring-before($idstr,' ')"/> <xsl:choose> <xsl:when test="$first0"> <xsl:copy-of select="$first0"/> </xsl:when> <xsl:otherwise> <xsl:copy-of select="$idstr"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:if test="string-length($first)"> <xsl:call-template name='recursively-apply-first-of'> <xsl:with-param name="idstr"> <xsl:value-of select="substring-after($idstr,' ')"/> </xsl:with-param> </xsl:call-template> <xsl:apply-templates select='//author[@id=$first]|//name[@id=$first]' /> </xsl:if> </xsl:template>

<xsl:template match="@* | author | title [name(..)='bibl'] | editor |      biblScope | edition | date[name(..)='bibl'] | publisher | pubPlace |       note[name(..)='bibl']"> <xsl:choose> <xsl:when test='@corresp'> <xsl:apply-templates select='id(@corresp)' /> </xsl:when> <xsl:otherwise> <xsl:copy> <xsl:apply-templates select="@*[not(name='TEIform')]|node|text"/> </xsl:copy> </xsl:otherwise> </xsl:choose> </xsl:template>

<xsl:template match='bibl/series'> <xsl:text>abc</xsl:text> <xsl:copy-of select='*/node' /> </xsl:template>

<xsl:template match="bibl/text|author/text|editor/text|title[name(..)='bibl']/text|biblScope/text|date[name(..)='bibl']/text|edition/text|pubPlace/text|publisher/text|note[name(..)='bibl']/text"> <xsl:copy /> </xsl:template>

</xsl:stylesheet>