Skip to content

Instantly share code, notes, and snippets.

@CJHArch
Created August 25, 2015 19:03
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 CJHArch/c20d57be953e78cadfc3 to your computer and use it in GitHub Desktop.
Save CJHArch/c20d57be953e78cadfc3 to your computer and use it in GitHub Desktop.
TSV out of EAD
<?xml version="1.0" encoding="UTF-8"?>
<!-- This stylesheet will generate a tsv file from an EAD container list. It will catch all c0X elements that have a did/container child -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- We don't want an xml declaration in the output, since this will just be a tab-separated text file-->
<xsl:output omit-xml-declaration="yes"/>
<!-- We don't want extra space floating around -->
<xsl:strip-space elements="*"/>
<!-- This will grab each did that has a container child (the for-each statement), and then output the value of the children. The normalize-space command is needed to remove extra odd space that sometimes happens within elements -->
<xsl:template match="/">
<xsl:for-each select="ead/archdesc/dsc//did[container]">
<xsl:value-of select="normalize-space(container[1])"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="normalize-space(container[2])"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="normalize-space(unittitle)"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="normalize-space(unitdate)"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="normalize-space(../scopecontent/p)"/>
<xsl:text>&#10;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment