Created
February 1, 2011 01:44
-
-
Save sgsinclair/805255 to your computer and use it in GitHub Desktop.
A variant of https://gist.github.com/805081 for variable-based sorting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0"> | |
<xsl:output method="html"/> | |
<xsl:template match="/"> | |
<xsl:param name="sortField"/> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | |
<head> | |
<title>Bibliography</title> | |
</head> | |
<body> | |
<xsl:choose> | |
<xsl:when test="$sortField='authors'"> | |
<xsl:for-each select="//record"> | |
<xsl:sort select="authors"/> | |
<xsl:apply-templates/> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:when test="$sortField='dates'"> | |
<xsl:for-each select="//record"> | |
<xsl:sort select="dates"/> | |
<xsl:apply-templates/> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:when test="$sortField='titles'"> | |
<xsl:for-each select="//record"> | |
<xsl:sort select="titles"/> | |
<xsl:apply-templates/> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:apply-templates select="//record"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template match="record"> | |
<div class="record"> | |
<hr/> | |
<p><strong>Record Number: </strong> | |
<xsl:value-of select="rec-number"/><br/><br/> | |
<xsl:value-of select="contributors/authors/author"/> | |
<xsl:text>. </xsl:text> | |
<em><xsl:value-of select="titles/title"/>. </em> | |
<xsl:value-of select="pub-location"/>: <xsl:value-of select="publisher"/>, | |
<xsl:value-of select="dates/year"/>. <xsl:value-of select="pages"/> | |
</p> | |
</div> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment