[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: MHRA Style Sheet Update
Hi Everyone, I have updated my MHRA style sheet to include styling the bibliography. I have also implemented the bibliography sorting code (thanks to Mr. Stayton) from http://www.sagehill.net/docbookxsl/SortBiblio.html. One concern that I do have is explaining to someone in the humanities why you have to wrap your biblioentries in a bibliodiv. I did have a look at the biblio.xsl in the fo directory and decided that using the bibliodiv was a much better idea. If anyone has and suggestions for improvement or comments, I would be more than happy to hear them. Thanks, Chris
<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:d="http://docbook.org/ns/docbook" exclude-result-prefixes="d"> <xsl:template match="biblioref[ancestor::footnote]"> <xsl:choose> <xsl:when test="key('id', @linkend)/biblioset[@relation='article']"> <xsl:call-template name="MHRA.article-ref" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="MHRA.book-ref" /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="MHRA.book-ref"> <xsl:variable name="linkend" select="@linkend" /> <xsl:choose> <xsl:when test="preceding-sibling::biblioref[@linkend=$linkend]"> <xsl:call-template name="MHRA.book-ref-ibid" /> </xsl:when> <xsl:when test="preceding::biblioref[@linkend=$linkend]"> <xsl:call-template name="MHRA.book-ref-short" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="MHRA.book-ref-full" /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="MHRA.book-ref-ibid"> <xsl:text>ibid., </xsl:text> <xsl:choose> <xsl:when test="@begin=@end"> <xsl:text>, p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and not(@end)"> <xsl:text>, p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="not(@begin) and @end"> <xsl:text>, p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and @end"> <xsl:text>, pp. </xsl:text><xsl:value-of select="@begin" /><xsl:text>-</xsl:text><xsl:value-of select="@end" /> </xsl:when> </xsl:choose> <xsl:text>.</xsl:text> </xsl:template> <xsl:template name="MHRA.book-ref-short"> <xsl:variable name="linkend" select="@linkend" /> <xsl:variable name="bibentry" select="key('id', @linkend)" /> <xsl:choose> <xsl:when test="$bibentry/author"> <xsl:value-of select="$bibentry/author//surname" /> </xsl:when> <xsl:when test="$bibentry/authorgroup"> <xsl:for-each select="$bibentry/authorgroup/author"> <xsl:value-of select=".//surname" /> <xsl:if test="not(last())"> <xsl:text> and </xsl:text> </xsl:if> </xsl:for-each> </xsl:when> </xsl:choose> <xsl:text>, </xsl:text> <fo:inline font-style="italic"> <xsl:value-of select="$bibentry/title" /> </fo:inline> <xsl:choose> <xsl:when test="@begin=@end"> <xsl:text>, p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and not(@end)"> <xsl:text>, p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="not(@begin) and @end"> <xsl:text>, p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and @end"> <xsl:text>, pp. </xsl:text><xsl:value-of select="@begin" /><xsl:text>-</xsl:text><xsl:value-of select="@end" /> </xsl:when> </xsl:choose> <xsl:text>.</xsl:text> </xsl:template> <xsl:template name="MHRA.book-ref-full"> <xsl:variable name="linkend" select="@linkend" /> <xsl:variable name="bibentry" select="key('id', @linkend)" /> <xsl:choose> <xsl:when test="$bibentry/authorgroup/author"> <xsl:for-each select="$bibentry/authorgroup/author"> <xsl:value-of select="$bibentry/author//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$bibentry/author//surname" /> <xsl:if test="not(last())"> <xsl:text> and </xsl:text> </xsl:if> </xsl:for-each> <xsl:text>, </xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="$bibentry/author//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$bibentry/author//surname" /> <xsl:text>, </xsl:text> </xsl:otherwise> </xsl:choose> <fo:inline font-style="italic"> <xsl:value-of select="$bibentry/title" /> <xsl:if test="$bibentry/subtitle"> <xsl:text>: </xsl:text> <xsl:value-of select="$bibentry/subtitle" /> </xsl:if> </fo:inline> <xsl:text>, </xsl:text> <xsl:choose> <xsl:when test="$bibentry/authorgroup/editor"> <xsl:text>ed. by </xsl:text> <xsl:for-each select="$bibentry/authorgroup/editor"> <xsl:value-of select="$bibentry/authorgroup/editor//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$bibentry/authorgroup/editor//surname" /> <xsl:if test="not(last())"> <xsl:text> and </xsl:text> </xsl:if> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:text>ed. by </xsl:text> <xsl:value-of select="$bibentry/editor//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$bibentry/editor//surname" /> </xsl:otherwise> </xsl:choose> <xsl:if test="$bibentry/edition"> <xsl:text>, </xsl:text> <xsl:value-of select="$bibentry/edition" /> </xsl:if> <xsl:if test="$bibentry/volumenum"> <xsl:text>, vols. </xsl:text> <xsl:value-of select="$bibentry/volumenum" /> </xsl:if> <xsl:text> (</xsl:text> <xsl:value-of select="$bibentry/address" /> <xsl:text>: </xsl:text> <xsl:value-of select="$bibentry/publishername" /> <xsl:text>, </xsl:text> <xsl:value-of select="$bibentry/copyright/year" /> <xsl:text>)</xsl:text> <xsl:choose> <xsl:when test="@begin=@end"> <xsl:text>, p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and not(@end)"> <xsl:text>, p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="not(@begin) and @end"> <xsl:text>, p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and @end"> <xsl:text>, pp. </xsl:text><xsl:value-of select="@begin" /><xsl:text>-</xsl:text><xsl:value-of select="@end" /> </xsl:when> </xsl:choose> <xsl:text>.</xsl:text> </xsl:template> <xsl:template name="MHRA.article-ref"> <xsl:variable name="linkend" select="@linkend" /> <xsl:variable name="bibentry" select="key('id', @linkend)" /> <xsl:choose> <xsl:when test="preceding-sibling::biblioref[@linkend=$linkend]"> <xsl:call-template name="MHRA.article-ibid" /> </xsl:when> <xsl:when test="preceding::biblioref[@linkend=$linkend]"> <xsl:call-template name="MHRA.article-short" /> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="$bibentry/biblioset[@relation='journal']"> <xsl:call-template name="MHRA.article-ref-journal" /> </xsl:when> <xsl:when test="$bibentry/biblioset[@relation='incollection']"> <xsl:call-template name="MHRA.article-ref-incollection" /> </xsl:when> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="MHRA.article-ibid"> <xsl:text>ibid., </xsl:text> <xsl:choose> <xsl:when test="@begin=@end"> <xsl:text>p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and not(@end)"> <xsl:text>p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="not(@begin) and @end"> <xsl:text>p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and @end"> <xsl:text>pp. </xsl:text><xsl:value-of select="@begin" /><xsl:text>-</xsl:text><xsl:value-of select="@end" /> </xsl:when> </xsl:choose> <xsl:text>.</xsl:text> </xsl:template> <xsl:template name="MHRA.article-short"> <xsl:variable name="linkend" select="@linkend" /> <xsl:variable name="bibentry" select="key('id', @linkend)" /> <xsl:value-of select="$bibentry/author//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$bibentry/author//lastname" /> <xsl:text>, ‘</xsl:text> <xsl:value-of select="$bibentry/title" /> <xsl:text>’, </xsl:text> <xsl:choose> <xsl:when test="@begin=@end"> <xsl:text>p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and not(@end)"> <xsl:text>p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="not(@begin) and @end"> <xsl:text>p. </xsl:text><xsl:value-of select="@begin" /> </xsl:when> <xsl:when test="@begin and @end"> <xsl:text>pp. </xsl:text><xsl:value-of select="@begin" /><xsl:text>-</xsl:text><xsl:value-of select="@end" /> </xsl:when> </xsl:choose> <xsl:text>.</xsl:text> </xsl:template> <xsl:template name="MHRA.article-ref-journal"> <xsl:variable name="linkend" select="@linkend" /> <xsl:variable name="bibentry-article" select="key('id', @linkend)/biblioset[@relation='article']" /> <xsl:variable name="bibentry-journal" select="key('id', @linkend)/biblioset[@relation='journal']" /> <xsl:value-of select="$bibentry-article/author//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$bibentry-article/author//surname" /> <xsl:text>, ‘</xsl:text> <xsl:value-of select="$bibentry-article/title" /> <xsl:if test="$bibentry-article/subtitle" > <xsl:value-of select="$bibentry-article/subtitle" /> </xsl:if> <xsl:text>’, </xsl:text> <fo:inline font-style="italic"> <xsl:value-of select="$bibentry-journal/title" /> </fo:inline> <xsl:text>, </xsl:text> <xsl:value-of select="$bibentry-journal/issuenum" /> <xsl:text> (</xsl:text> <xsl:value-of select="$bibentry-journal/date" /> <xsl:text>), </xsl:text> <xsl:value-of select="$bibentry-article/pagenums"/> <xsl:choose> <xsl:when test="@begin and @end"> <xsl:text> (</xsl:text> <xsl:text>pp. </xsl:text> <xsl:value-of select="@begin" /> <xsl:text>-</xsl:text> <xsl:value-of select="@end" /> <xsl:text>)</xsl:text> <xsl:text>.</xsl:text> </xsl:when> <xsl:when test="@begin and not(@end)"> <xsl:text> (</xsl:text> <xsl:text>p. </xsl:text> <xsl:value-of select="@begin" /> <xsl:text>)</xsl:text> <xsl:text>.</xsl:text> </xsl:when> <xsl:when test="not(@begin) and @end"> <xsl:text> (</xsl:text> <xsl:text>p. </xsl:text> <xsl:value-of select="@end" /> <xsl:text>)</xsl:text> <xsl:text>.</xsl:text> </xsl:when> </xsl:choose> </xsl:template> <xsl:template name="MHRA.article-ref-incollection"> <xsl:variable name="linkend" select="@linkend" /> <xsl:variable name="bibentry-article" select="key('id', @linkend)/biblioset[@relation='article']" /> <xsl:variable name="bibentry-incollection" select="key('id', @linkend)/biblioset[@relation='incollection']" /> <xsl:value-of select="$bibentry-article/author//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$bibentry-article/author//surname" /> <xsl:text>, ‘</xsl:text> <xsl:value-of select="$bibentry-article/title" /> <xsl:if test="$bibentry-article/subtitle"> <xsl:text>: </xsl:text> <xsl-value-of select="$bibentry-article/subtitle" /> </xsl:if> <xsl:text>’ in </xsl:text> <fo:inline font-style="italic"> <xsl:value-of select="$bibentry-incollection/title" /> </fo:inline> <xsl:text>, ed. by </xsl:text> <xsl:choose> <xsl:when test="$bibentry-incollection/authorgroup"> <xsl:for-each select="$bibentry-incollection/authorgroup/editor"> <xsl:value-of select="$bibentry-incollection/editor//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$bibentry-incollection/editor//surname" /> <xsl:if test="not(last())"> <xsl:text> and </xsl:text> </xsl:if> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:value-of select="$bibentry-incollection/editor//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$bibentry-incollection/editor//surname" /> </xsl:otherwise> </xsl:choose> <xsl:text> (</xsl:text> <xsl:value-of select="$bibentry-incollection/address" /> <xsl:text>: </xsl:text> <xsl:value-of select="$bibentry-incollection/publishername" /> <xsl:text>, </xsl:text> <xsl:value-of select="$bibentry-incollection/date" /> <xsl:text>), pp. </xsl:text> <xsl:value-of select="$bibentry-article/pagenums" /> <xsl:choose> <xsl:when test="@begin and @end"> <xsl:text> (pp. </xsl:text> <xsl:value-of select="@begin" /> <xsl:text>-</xsl:text> <xsl:value-of select="@end" /> <xsl:text>).</xsl:text> </xsl:when> <xsl:when test="@begin and not(@end)"> <xsl:text> (p. </xsl:text> <xsl:value-of select="@begin" /> <xsl:text>).</xsl:text> </xsl:when> <xsl:when test="@begin=@end"> <xsl:text> (p. </xsl:text> <xsl:value-of select="@begin" /> <xsl:text>).</xsl:text> </xsl:when> <xsl:when test="not(@begin) and @end"> <xsl:text> (p. </xsl:text> <xsl:value-of select="@end" /> <xsl:text>).</xsl:text> </xsl:when> </xsl:choose> </xsl:template> <!-- Bibliography Styling --> <xsl:template match="bibliodiv"> <xsl:variable name="lang"> <xsl:call-template name="l10n.language"/> </xsl:variable> <fo:block> <xsl:attribute name="id"> <xsl:call-template name="object.id"/> </xsl:attribute> <xsl:call-template name="bibliodiv.titlepage"/> <xsl:apply-templates select="*[not(self::biblioentry)]"/> <xsl:apply-templates select="biblioentry"> <xsl:sort select="author[1]//surname" lang="$lang" data-type="text" order="ascending"/> </xsl:apply-templates> </fo:block> </xsl:template> <xsl:template match="biblioentry"> <fo:block text-indent="-4em" start-indent="4em"> <xsl:choose> <xsl:when test="biblioset[@relation='journal']"> <xsl:call-template name="MHRA.bib-journal-article" /> </xsl:when> <xsl:when test="biblioset[@relation='incollection']"> <xsl:call-template name="MHRA.bib-incollection-article" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="MHRA.bib-book" /> </xsl:otherwise> </xsl:choose> </fo:block> </xsl:template> <xsl:template name="MHRA.bib-book"> <xsl:choose> <xsl:when test="authorgroup/author"> <xsl:for-each select="authorgroup/author"> <xsl:value-of select="surname" /> <xsl:text>, </xsl:text> <xsl:value-of select="firstname" /> <xsl:if test="not(last())"> <xsl:text> and </xsl:text> </xsl:if> </xsl:for-each> <xsl:text>, </xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="author//surname" /> <xsl:text>, </xsl:text> <xsl:value-of select="author//firstname" /> <xsl:text>, </xsl:text> </xsl:otherwise> </xsl:choose> <xsl:if test="not(author|authorgroup/author)"> <xsl:choose> <xsl:when test="authorgroup/editor"> <xsl:for-each select="authorgroup/editor"> <xsl:value-of select="personname/surname" /> <xsl:text>,</xsl:text> <xsl:value-of select="personname/firstname" /> <xsl:if test="not(last())"> <xsl:text> and </xsl:text> </xsl:if> </xsl:for-each> <xsl:text>, eds.</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="authorgroup/editor//surname" /> <xsl:text>, </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:if> <fo:inline font-style="italic"> <xsl:value-of select="title" /> <xsl:if test="subtitle"> <xsl:text>: </xsl:text> <xsl:value-of select="subtitle" /> </xsl:if> </fo:inline> <xsl:if test="author|authorgroup/author"> <xsl:choose> <xsl:when test="authorgroup/editor"> <xsl:for-each select="authorgroup/editor"> <xsl:value-of select="personname/firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="personname/surname" /> <xsl:if test="not(last())"> <xsl:text> and </xsl:text> </xsl:if> </xsl:for-each> <xsl:text>, eds.</xsl:text> </xsl:when> <xsl:when test="editor"> <xsl:value-of select="authorgroup/editor/prersonname/firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="authorgroup/editor/prersonname/surname" /> <xsl:text>, ed</xsl:text> </xsl:when> </xsl:choose> </xsl:if> <xsl:if test="volumenum"> <xsl:text>, </xsl:text> <xsl:value-of select="volumenum" /> <xsl:text> vols. </xsl:text> </xsl:if> <xsl:text>(</xsl:text> <xsl:value-of select="address" /> <xsl:text>: </xsl:text> <xsl:value-of select="publishername" /> <xsl:text>, </xsl:text> <xsl:value-of select="copyright/year" /> <xsl:text>)</xsl:text> </xsl:template> <xsl:template name="MHRA.bib-journal-article"> <xsl:variable name="article" select="biblioset[@relation='article']" /> <xsl:variable name="journal" select="biblioset[@relation='journal']" /> <xsl:value-of select="$article/author//surname" /> <xsl:text>, </xsl:text> <xsl:value-of select="$article/author//firstname" /> <xsl:text>, ‘</xsl:text> <xsl:value-of select="$article/title" /> <xsl:if test="subtitle"> <xsl:text>: </xsl:text> <xsl:value-of select="$article/subtitle" /> </xsl:if> <xsl:text>’, </xsl:text> <fo:inline font-style="italic"> <xsl:value-of select="$journal/title" /> <xsl:if test="$journal/subtitle"> <xsl:text>: </xsl:text> <xsl:value-of select="$journal/subtitle" /> </xsl:if> </fo:inline> <xsl:text>, </xsl:text> <xsl:value-of select="$journal/issuenum" /> <xsl:text> (</xsl:text> <xsl:value-of select="$journal/date" /> <xsl:text>), pp. </xsl:text> <xsl:value-of select="$article/pagenums" /> </xsl:template> <xsl:template name="MHRA.bib-incollection-article"> <xsl:variable name="article" select="biblioset[@relation='article']" /> <xsl:variable name="incollection" select="biblioset[@relation='incollection']" /> <xsl:value-of select="$article/author//surname" /> <xsl:text>, </xsl:text> <xsl:value-of select="$article/author//firstname" /> <xsl:text>, ‘</xsl:text> <xsl:value-of select="$article/title" /> <xsl:if test="$article/subtitle"> <xsl:text>: </xsl:text> <xsl:value-of select="$article/subtitle" /> </xsl:if> <xsl:text>’, in </xsl:text> <fo:inline font-style="italic"> <xsl:value-of select="$incollection/title" /> <xsl:if test="$incollection/subtitle"> <xsl:text>: </xsl:text> <xsl:value-of select="$incollection/subtitle" /> </xsl:if> </fo:inline> <xsl:text>, ed. by </xsl:text> <xsl:choose> <xsl:when test="$incollection/authorgroup"> <xsl:for-each select="$incollection/authorgroup/editor"> <xsl:value-of select="personname/firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="personname/surname" /> <xsl:if test="not(last())"> <xsl:text> and </xsl:text> </xsl:if> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:value-of select="$incollection/editor//firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="$incollection/editor//surname" /> </xsl:otherwise> </xsl:choose> <xsl:text> (</xsl:text> <xsl:value-of select="$incollection/address" /> <xsl:text>: </xsl:text> <xsl:value-of select="$incollection/publishername" /> <xsl:text>, </xsl:text> <xsl:value-of select="$incollection/date" /> <xsl:text>), pp. </xsl:text> <xsl:value-of select="$article/pagenums" /> </xsl:template> </xsl:stylesheet>
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]