Skip to content

Instantly share code, notes, and snippets.

@Phu2
Created May 8, 2017 15:50
Show Gist options
  • Save Phu2/20e79c2b5deb5222fd96e64afa3f2785 to your computer and use it in GitHub Desktop.
Save Phu2/20e79c2b5deb5222fd96e64afa3f2785 to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<ead>
<eadheader>...</eadheader>
<xsl:choose>
<xsl:when test="//line[1]/@collection">
<archdesc level="{//line[1]/@collection}" id="{//line[1]/@id}">
<xsl:apply-templates select="//line[@parent = '']"/>
</archdesc>
</xsl:when>
<xsl:otherwise>
<xsl:text>Cannot locate : </xsl:text><xsl:value-of select="//line[1]/@collection"/>
</xsl:otherwise>
</xsl:choose>
</ead>
</xsl:template>
<xsl:template match="line">
<xsl:variable name="id" select="@id"/>
<xsl:variable name="collection" select="@collection"/>
<c level="{$collection}" id="{$id}">
<xsl:if test="../line[@parent = current()/@id]">
<xsl:apply-templates select="../line[@parent = current()/@id]"/>
</xsl:if>
</c>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment