Skip to content

Instantly share code, notes, and snippets.

@richard-srnsw
Created February 1, 2011 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richard-srnsw/7ae9c2f8605038f927b9 to your computer and use it in GitHub Desktop.
Save richard-srnsw/7ae9c2f8605038f927b9 to your computer and use it in GitHub Desktop.
<?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="pSortNameAuth" select="'authors'"/>
<xsl:param name="pSortNameYear" select="'dates'"/>
<xsl:param name="pSortNameTitle" select="'titles'"/>
<xsl:param name="pSortPosition" select="1"/>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Bibliography</title>
<script type="text/javascript">
<xsl:text>
function reveal(target) {
if (target=='author') {
document.getElementById('publication').style.display = 'none';
document.getElementById('title').style.display = 'none';
document.getElementById('author').style.display = '';
}
if (target=='publication') {
document.getElementById('author').style.display = 'none';
document.getElementById('title').style.display = 'none';
document.getElementById('publication').style.display = '';
}
if (target=='title') {
document.getElementById('author').style.display = 'none';
document.getElementById('publication').style.display = 'none';
document.getElementById('title').style.display = '';
}
}
</xsl:text>
</script>
</head>
<body>
<p>Sort by: <a href="#top" onclick="reveal('author')">Author</a> | <a href="#top" onclick="reveal('publication')">Year of publication</a> | <a href="#top" onclick="reveal('title')">Title</a></p>
<div id="author">
<xsl:for-each select="//record">
<xsl:sort select=".//*[name()=$pSortNameAuth]/*[position()=$pSortPosition]"/>
<xsl:apply-templates/>
</xsl:for-each>
</div>
<div id="publication" style="display: none">
<xsl:for-each select="//record">
<xsl:sort select=".//*[name()=$pSortNameYear]/*[position()=$pSortPosition]"/>
<xsl:apply-templates/>
</xsl:for-each>
</div>
<div id="title" style="display: none">
<xsl:for-each select="//record">
<xsl:sort select=".//*[name()=$pSortNameTitle]/*[position()=$pSortPosition]"/>
<xsl:apply-templates/>
</xsl:for-each>
</div>
</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