Skip to content

Instantly share code, notes, and snippets.

@CJHArch
Created February 27, 2015 20:25
Show Gist options
  • Save CJHArch/3426cb04299e7008dd72 to your computer and use it in GitHub Desktop.
Save CJHArch/3426cb04299e7008dd72 to your computer and use it in GitHub Desktop.
This XSLT will take a list of PIDs, turn them into file names, and then look at those EAD files and pull out the genreforms.
<?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">
<xsl:template match="/">
<xsl:for-each select="document('PIDsforEADs.xml')/record/pid">
<record>
<xsl:variable name="PID" select="."></xsl:variable>
<PID>
<xsl:value-of select="$PID"></xsl:value-of>
</PID>
<xsl:variable name="doc">
<xsl:value-of select="concat($PID, '.xml')"></xsl:value-of>
</xsl:variable>
<xsl:for-each select="document($doc)//genreform">
<term>
<xsl:value-of select="."/>
</term>
</xsl:for-each>
</record>
</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