Hi there,
This is the stylesheet (hope it comes through OK on the forum):
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="
http://www.w3.org/1999/XSL/Format">
<!-- Bibliography elements, going to MLA style. This is complicated! -->
<!-- First, make sure the items are processed in a list, sorted into the correct order. -->
<xsl:template match="listBibl">
<fo:list-block provisional-distance-between-starts="0" provisional-label-separation="0" space-before="0.25cm" space-after="0.25cm">
<xsl:for-each select="biblStruct">
<xsl:sort select="descendant::name[1]/@reg" data-type="text" order="ascending"></xsl:sort>
<xsl:sort select="descendant::name[2]/@reg" data-type="text" order="ascending"></xsl:sort>
<xsl:sort select="descendant::date" data-type="text" order="ascending"></xsl:sort>
<fo:list-item space-after="0.5em">
<fo:list-item-label end-indent="label-end()">
<fo:block></fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates select=".">
<!--<xsl:sort select="descendant::name[1]/@reg" data-type="text" order="ascending"></xsl:sort>
<xsl:sort select="descendant::name[2]/@reg" data-type="text" order="ascending"></xsl:sort>
<xsl:sort select="descendant::date" data-type="text" order="ascending"></xsl:sort>-->
</xsl:apply-templates>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:for-each>
</fo:list-block>
</xsl:template>
<!-- Suppress the head element: already handled. -->
<xsl:template match="div[@type='Bibliography']/head"></xsl:template>
<!-- We need a template to handle each of the title types appropriately. -->
<!-- Basic book title: -->
<xsl:template name="MonographTitle">
<xsl:param name="InTitle"/>
<xsl:if test="string-length($InTitle) > 0">
<fo:inline font-style="italic"><xsl:apply-templates select="$InTitle" /><xsl:if test="not(substring($InTitle/text(), string-length(InTitle/text()))='?')"><xsl:text>. </xsl:text></xsl:if></fo:inline>
</xsl:if>
</xsl:template>
<!-- Journal title (no final period, because volume info will follow. -->
<xsl:template name="JournalTitle">
<xsl:param name="InTitle"/>
<xsl:if test="string-length($InTitle) > 0">
<fo:inline font-style="italic"><xsl:apply-templates select="$InTitle" /></fo:inline><xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<!-- Analytic (article or chapter) title. -->
<xsl:template name="AnalyticTitle">
<xsl:param name="InTitle"/>
<xsl:if test="string-length($InTitle) > 0">
"<xsl:value-of select="$InTitle" /><xsl:if test="not(substring($InTitle/text(), string-length(InTitle/text()))='?')">.</xsl:if>"<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<!-- Unpublished article, lecture or dissertation: the title would be analytic, normally, and the title level="u" element used to record the location.. -->
<xsl:template name="UnpublishedTitle">
<xsl:param name="InTitle"/>
<xsl:if test="string-length($InTitle) > 0">
<xsl:value-of select="$InTitle" /><xsl:if test="not(substring($InTitle/text(), string-length(InTitle/text()))='?')">.</xsl:if><xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<!-- Template to process a nodelist consisting of name elements -->
<xsl:template name="ProcessNameList">
<xsl:param name="Names" />
<xsl:param name="ReverseFirst" />
<xsl:param name="AddPeriod" />
<!--<xsl:if test="count($Names//name) > 0">-->
<xsl:for-each select="$Names/name">
<xsl:variable name="NameToUse">
<xsl:choose>
<xsl:when test="position()=1 and $ReverseFirst='true'"><xsl:value-of select="@reg" /></xsl:when>
<xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="position()=1"><xsl:value-of select="$NameToUse" /></xsl:if>
<xsl:if test="position()>1">,
<xsl:if test="position()=last()">and </xsl:if>
<xsl:value-of select="$NameToUse" />
</xsl:if>
<xsl:if test="position()=last()">
<xsl:if test="$AddPeriod='true'">
<xsl:if test="not(substring($NameToUse, string-length($NameToUse))='.')"><xsl:text>.</xsl:text></xsl:if><xsl:text> </xsl:text>
</xsl:if>
</xsl:if>
</xsl:for-each>
<!--</xsl:if>-->
</xsl:template>
<!-- This template processes authors and editors from a container passed to it. -->
<xsl:template name="ProcessAuthorsAndEditors">
<xsl:param name="TheParent" />
<xsl:param name="ReverseFirst" />
<xsl:choose>
<!-- If there are authors, process them first-->
<xsl:when test="$TheParent/author">
<xsl:call-template name="ProcessNameList">
<xsl:with-param name="Names" select="$TheParent//author" />
<xsl:with-param name="ReverseFirst" select="$ReverseFirst" />
<xsl:with-param name="AddPeriod">true</xsl:with-param>
</xsl:call-template>
<!--Then process editors-->
<xsl:if test="$TheParent/editor">
<xsl:text>Ed. </xsl:text>
<xsl:call-template name="ProcessNameList">
<xsl:with-param name="Names" select="$TheParent//editor" />
<xsl:with-param name="ReverseFirst">false</xsl:with-param>
<xsl:with-param name="AddPeriod">true</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:when>
<!--Otherwise process the editors as the primary set-->
<xsl:otherwise>
<xsl:if test="$TheParent/editor">
<xsl:call-template name="ProcessNameList">
<xsl:with-param name="Names" select="$TheParent//editor" />
<xsl:with-param name="ReverseFirst" select="$ReverseFirst" />
<xsl:with-param name="AddPeriod">false</xsl:with-param>
</xsl:call-template>
<xsl:choose>
<xsl:when test="count($TheParent//editor) > 1"><xsl:text>, eds. </xsl:text></xsl:when>
<xsl:otherwise><xsl:text>, ed. </xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- This template handles processing of the monogr element for non-journal items. -->
<xsl:template name="ProcessMonogr">
<xsl:param name="TheParent" /><!-- the monogr element that's being processed. -->
<xsl:param name="IsContainer" /><!-- Is this a monogr containing another (analytic) document? -->
<xsl:choose>
<xsl:when test="$IsContainer='true'">
<!-- If it's a container, then it presumably doesn't have authors. -->
<!-- Title comes first, then editors. -->
<xsl:call-template name="MonographTitle">
<xsl:with-param name="InTitle" select="$TheParent/title[@level='m']" />
</xsl:call-template>
<!-- Handle any translators etc.. -->
<xsl:if test="monogr/respStmt">
<xsl:call-template name="ProcessResps">
<xsl:with-param name="TheParent" select="$TheParent/respStmt" />
</xsl:call-template>
</xsl:if>
<!-- Now handle editors. -->
<xsl:if test="$TheParent/editor">
<xsl:text>Ed. </xsl:text>
<xsl:call-template name="ProcessNameList">
<xsl:with-param name="Names" select="$TheParent//editor" />
<xsl:with-param name="ReverseFirst">false</xsl:with-param>
<xsl:with-param name="AddPeriod">true</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<!-- If it's a standalone, then process the authors/editors first. -->
<xsl:call-template name="ProcessAuthorsAndEditors">
<xsl:with-param name="TheParent" select="$TheParent" />
<xsl:with-param name="ReverseFirst">true</xsl:with-param>
<xsl:with-param name="AddPeriod">true</xsl:with-param>
</xsl:call-template>
<!-- Handle monograph and unpublished titles. -->
<xsl:call-template name="MonographTitle">
<xsl:with-param name="InTitle" select="$TheParent/title[@level='m']" />
</xsl:call-template>
<xsl:call-template name="UnpublishedTitle">
<xsl:with-param name="InTitle" select="$TheParent/title[@level='u']" />
</xsl:call-template>
<xsl:if test="monogr/respStmt">
<xsl:call-template name="ProcessResps">
<xsl:with-param name="TheParent" select="$TheParent/respStmt" />
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<!-- Now handle the edition, volumes, imprint and other info .-->
<xsl:if test="$TheParent/edition">
<xsl:value-of select="$TheParent/edition" /><xsl:text>. </xsl:text>
</xsl:if>
<xsl:if test="$TheParent/title[@level='s']">
<xsl:value-of select="$TheParent/title[@level='s']" /><xsl:text>. </xsl:text>
</xsl:if>
<xsl:if test="$TheParent/extent">
<xsl:value-of select="$TheParent/extent" /><xsl:text>. </xsl:text>
</xsl:if>
<xsl:if test="$TheParent/imprint/pubPlace">
<xsl:value-of select="$TheParent/imprint/pubPlace" />
</xsl:if>
<xsl:if test="$TheParent/imprint/pubPlace and $TheParent/imprint/publisher">
<xsl:text>: </xsl:text>
</xsl:if>
<xsl:if test="$TheParent/imprint/publisher">
<xsl:value-of select="$TheParent/imprint/publisher" />
</xsl:if>
<xsl:if test="($TheParent/imprint/pubPlace or $TheParent/imprint/publisher) and $TheParent/imprint/date">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="$TheParent/imprint/date">
<xsl:value-of select="$TheParent/imprint/date" />
</xsl:if>
<xsl:if test="$TheParent/imprint/biblScope[@type='pages']">
<xsl:text>, </xsl:text><xsl:value-of select="$TheParent/imprint/biblScope[@type='pages']" />
</xsl:if>
<xsl:if test="string-length($TheParent/imprint) > 0"><xsl:text>. </xsl:text></xsl:if>
</xsl:template>
<!-- This template handles processing of a journal which is a container for an article. -->
<xsl:template name="ProcessJournal">
<xsl:param name="TheParent" />
<xsl:call-template name="JournalTitle">
<xsl:with-param name="InTitle" select="$TheParent/title" />
</xsl:call-template>
<xsl:text> </xsl:text>
<xsl:value-of select="$TheParent/imprint/biblScope[@type='vol']" />
<xsl:text> </xsl:text>
<xsl:text>(</xsl:text><xsl:value-of select="$TheParent/imprint/date" /><xsl:text>)</xsl:text>
<xsl:text>: </xsl:text>
<xsl:value-of select="$TheParent/imprint/biblScope[@type='pages']" />
<xsl:text>. </xsl:text>
</xsl:template>
<!-- This template handles the processing of resp elements for things like translators. -->
<xsl:template name="ProcessResps">
<xsl:param name="TheParent" />
<xsl:if test="$TheParent/resp">
<xsl:value-of select="$TheParent/resp" /><xsl:text> </xsl:text>
</xsl:if>
<xsl:if test="$TheParent/name">
<xsl:call-template name="ProcessNameList">
<xsl:with-param name="ReverseFirst">false</xsl:with-param>
<xsl:with-param name="Names" select="$TheParent" />
<xsl:with-param name="AddPeriod">true</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- This is the bit that handles the actual entries. -->
<xsl:template match="biblStruct">
<xsl:if test="analytic">
<!-- Journal article or book chapter. These would not have editors, so let's assume all name elements are authors. -->
<xsl:call-template name="ProcessNameList">
<xsl:with-param name="Names" select="analytic//author" />
<xsl:with-param name="ReverseFirst">true</xsl:with-param>
<xsl:with-param name="AddPeriod">true</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="AnalyticTitle">
<xsl:with-param name="InTitle" select="analytic/title[@level='a']" />
</xsl:call-template>
</xsl:if>
<xsl:choose>
<xsl:when test="analytic">
<!-- there's an article or chapter already specified; what follows contains it. -->
<xsl:choose>
<xsl:when test="monogr/title[@level='j']">
<xsl:call-template name="ProcessJournal">
<xsl:with-param name="TheParent" select="monogr" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="ProcessMonogr">
<xsl:with-param name="IsContainer">true</xsl:with-param>
<xsl:with-param name="TheParent" select="monogr" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<!-- this is a monograph alone, and not a container. -->
<!-- is it a book or a journal? -->
<!-- it's a book or equivalent. -->
<xsl:call-template name="ProcessMonogr">
<xsl:with-param name="IsContainer">false</xsl:with-param>
<xsl:with-param name="TheParent" select="monogr" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="note" />
</xsl:template>
</xsl:stylesheet>
I'm on a deadline with a complicated project right now, so I'm not really in a position to test a beta release, but as soon as the dust clears next month I'll give it a go. If there's any other info I can provide, ask away.
Cheers,
Martin