<!-- Template to render a list of related topics field values -->
<xsl:template name="DisplayClassification">
  <xsl:param name="str" />
  <xsl:if test='string-length($str) &gt; 0'>
  -
    <xsl:call-template name="split">
      <xsl:with-param name="string" select="$str"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

<xsl:template match="node()|@*" mode="split" name="split">
  <xsl:param name="string" select="string()"/>
  <xsl:variable name="sep" select="';#'"/>
  <!-- Extract the first field into $tmp -->
  <xsl:variable name="tmp" select="substring-before($string, $sep)"/>
  <!-- If multiple fields are concatenated together, topics can end up with a ';' 
        prefix on their name.The following ensures that $topicname is stripped 
        of this if necessary -->
  <xsl:variable name="topicname">
    <xsl:choose>
      <xsl:when test="starts-with($tmp,';')">
        <xsl:value-of select="substring-after($tmp, ';')"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$tmp"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="rest1" select="substring-after($string, $sep)"/>
  <xsl:variable name="topicid" select="substring-before($rest1,$sep)"/>
  <xsl:variable name="rest2" select="substring-after($rest1,$sep)"/>
  <xsl:variable name="link" select="substring-before($rest2,$sep)"/>
  <xsl:variable name="rest3" select="substring-after($rest2,$sep)"/>
  <xsl:variable name="urn" select="substring-before($rest3,$sep)"/>
  <xsl:variable name="nextitem" select="substring-after($rest3,$sep)"/>
  <!-- Render the topic and link as an HTML anchor. You could replace
       this with your own rendering code -->
  <xsl:if test="$topicname and $link">
    <a>
      <xsl:attribute name="href">
        <xsl:value-of select="$link"/>
      </xsl:attribute>
      <xsl:value-of select="$topicname"/>
    </a>
  </xsl:if>
  <!-- Check if a recursive call should be made to parse the rest of the field -->
  <xsl:if test="contains($nextitem,$sep)">
    <xsl:text>, </xsl:text>
    <xsl:call-template name="split">
      <xsl:with-param name="string" select="$nextitem"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>
