Last active
December 18, 2015 21:34
-
-
Save fordmadox/3440893da6817907e4d1 to your computer and use it in GitHub Desktop.
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
<!-- i've been using this to sort top/circulating containers in EAD, but i need a way to do this in the ASpace staff/public interface, as well... | |
the gist is that boxes like 1, 2, 2a, 2b, 3, 4, should be able to be sorted in order, regardless of where they occur in a finding aid... and it should also use what ASpace calls container2 and container3 values for sorting if multiple components are displayed | |
... so component Y would sort before component X if component Y was box 12a, folder 22 and component X was box 12a, folder 29 | |
--> | |
<xsl:function name="mdc:container-to-number" as="xs:decimal"> | |
<xsl:param name="current-container" as="node()*"/> | |
<xsl:variable name="primary-container-number" select="replace($current-container, '\D', '')"/> | |
<xsl:variable name="primary-container-modify"> | |
<xsl:choose> | |
<xsl:when test="matches($current-container, '\D')"> | |
<xsl:analyze-string select="$current-container" regex="(\D)(\s?)"> | |
<xsl:matching-substring> | |
<xsl:value-of select="number(string-to-codepoints(upper-case(regex-group(1))))"/> | |
</xsl:matching-substring> | |
</xsl:analyze-string> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="00"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="id-attribue" select="$current-container/@id"/> | |
<xsl:variable name="secondary-container-number"> | |
<xsl:choose> | |
<xsl:when test="$current-container/following-sibling::ead:container[@parent eq $id-attribue][1]"> | |
<xsl:value-of select="format-number(number(replace($current-container/following-sibling::ead:container[@parent eq $id-attribue][1], '\D', '')), '000000')"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="000000"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="tertiary-container-number"> | |
<xsl:choose> | |
<xsl:when test="$current-container/following-sibling::ead:container[@parent eq $id-attribue][2]"> | |
<xsl:value-of select="format-number(number(replace($current-container/following-sibling::ead:container[@parent eq $id-attribue][2], '\D', '')), '000000')"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="000000"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:value-of select="xs:decimal(concat($primary-container-number, '.', $primary-container-modify, $secondary-container-number, $tertiary-container-number))"/> | |
</xsl:function> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment