<xsl:function name="tei:processInstruction" as="xs:string">
<xsl:param name="instr"/>
<xsl:choose>
<xsl:when test="matches($instr,'REF _')">
<!-- this will also catch NOTEREF _ -->
<xsl:value-of select="concat('#',substring-before(substring-after($instr,'_'),' '))"/>
</xsl:when>
<xsl:when test="matches($instr,' HYPERLINK \\l ')">
<xsl:variable name="target">
<xsl:value-of select="translate(tokenize($instr,' ')[4],$dq,'')"/>
</xsl:variable>
<xsl:value-of select="if (matches($target,'^_')) then concat('#',substring($target,2)) else $target"/>
</xsl:when>
<xsl:when test="matches($instr,' HYPERLINK')">
<xsl:variable name="target">
<xsl:value-of select="translate(tokenize($instr,' ')[2],$dq,'')"/>
</xsl:variable>
<xsl:value-of select="if (matches($target,'^_')) then concat('#',substring($target,2)) else $target"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="if (matches($instr,'^_')) then concat('#',substring($instr,2)) else $instr"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function> |