Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LincolnUniLTL/93980abeb39158c23c48 to your computer and use it in GitHub Desktop.
Save LincolnUniLTL/93980abeb39158c23c48 to your computer and use it in GitHub Desktop.
Our Symplectic Elements Repository Tools crosswalk custom templates
<?xml version="1.0" encoding="utf-8"?>
<!-- Lincoln override templates for Elements crosswalk transforms -->
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:crosswalks="info:symplectic/crosswalks"
xmlns:pubs="http://www.symplectic.co.uk/publications/atom-api"
version="1.0"
>
<!-- ***** Pagination field type ***** -->
<xsl:template match="pubs:pagination" mode="rangeandcount">
<!-- Child elements enumerated below to ensure sequence, not convinced a single unattributed xsl:apply-templates is safe here -->
<xsl:apply-templates select="pubs:begin-page" />
<xsl:apply-templates select="pubs:end-page" />
<xsl:apply-templates select="pubs:page-count" />
</xsl:template>
<xsl:template match="pubs:page-count">
<xsl:text> </xsl:text> <!-- gonna always want a leading space -->
<xsl:choose>
<xsl:when test="preceding-sibling::pubs:begin-page or preceding-sibling::pubs:end-page">
<xsl:text>(</xsl:text>
<xsl:apply-templates />
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="pubs:begin-page">
<xsl:apply-templates />
<xsl:if test="not(following-sibling::pubs:end-page)">
<xsl:text>-</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="pubs:end-page">
<xsl:text>-</xsl:text>
<xsl:apply-templates />
</xsl:template>
<!-- END: Pagination field type ***** -->
</xsl:transform>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment