Created
November 23, 2015 21:59
-
-
Save CJHArch/2c2aced7584e37c0727a 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
<?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"> | |
<!-- This template will take hyphen in the unittitle EAD tag and, in cases where it is between a lower-case letter and an upper-case letter, replace it within an em-dash --> | |
<!-- For example: <unittitle>Correspondence-Wax</unittitle> to <unittitle>Correspondence—Wax</unittitle> --> | |
<!-- Be sure to use an XSLT 2.0 engine --> | |
<xsl:template match="@*|node()"> | |
<xsl:copy> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="//unittitle/text()"> | |
<xsl:analyze-string select="." regex="[a-z]-[A-Z]"> | |
<xsl:matching-substring> | |
<xsl:value-of select="translate(., '-', '—')"/> | |
</xsl:matching-substring> | |
<xsl:non-matching-substring> | |
<xsl:value-of select="."/> | |
</xsl:non-matching-substring> | |
</xsl:analyze-string> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This template will take hyphen in the unittitle EAD tag and, in cases where it is between a lower-case letter and an upper-case letter, replace it within an em-dash