Skip to content

Instantly share code, notes, and snippets.

@CJHArch
Last active May 4, 2016 17:54
Show Gist options
  • Save CJHArch/86778ff96c1e9c1a16bd55e8d14bfa79 to your computer and use it in GitHub Desktop.
Save CJHArch/86778ff96c1e9c1a16bd55e8d14bfa79 to your computer and use it in GitHub Desktop.
Add sequential numbers to EAD folder titles. Each folder needed a consecutive number. Its xpath position matched the actual position in the finding aid.
<?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"
exclude-result-prefixes="xs"
version="2.0">
<!--copy everything-->
<!-- KS 20150831 This stylesheet takes the output from the Excel-to-DSC_CJH xsl and moves up the container to before the did -->
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="container">
<xsl:variable name="p">
<xsl:number count="c01/c02" from="dsc" level="any" />
</xsl:variable>
<xsl:variable name="t" select="./normalize-space()"/>
<xsl:element name="container">
<xsl:attribute name="type">folder</xsl:attribute>
<xsl:value-of select="$p"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="$t"/>
<xsl:text>)</xsl:text>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment