Skip to content

Instantly share code, notes, and snippets.

@eulereadgbe
Last active October 20, 2019 17:54
Show Gist options
  • Save eulereadgbe/cedc4310d57cb6119a9293d45d9159ac to your computer and use it in GitHub Desktop.
Save eulereadgbe/cedc4310d57cb6119a9293d45d9159ac to your computer and use it in GitHub Desktop.
XSLT to transform ASFA Thesaurus to DSpace controlled vocabulary
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="kConcByCode" match="CONCEPT" use="DESCRIPTOR"/>
<xsl:key name="useFor" match="CONCEPT" use="NON-DESCRIPTOR"/>
<xsl:template match="/">
<node id="ASFA" label="ASFA Thesaurus">
<isComposedBy>
<xsl:apply-templates select="/*/CONCEPT[not(BT)]"/>
</isComposedBy>
</node>
</xsl:template>
<xsl:template match="CONCEPT">
<node id="{DESCRIPTOR}" label="{DESCRIPTOR}">
<xsl:if test="key('kConcByCode', NT)">
<isComposedBy>
<xsl:apply-templates select="key('kConcByCode', NT)"/>
</isComposedBy>
</xsl:if>
</node>
</xsl:template>
<xsl:template match="CONCEPT[NON-DESCRIPTOR]">
<xsl:if test="key('useFor', NON-DESCRIPTOR)">
<node id="{NON-DESCRIPTOR}" label="{NON-DESCRIPTOR}, USE: {USE}"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment