<xsl:template name="makeInternalLink">
<xsl:param name="target"/>
<xsl:param name="ptr"/>
<xsl:param name="dest"/>
<xsl:param name="body"/>
<xsl:param name="class">
<xsl:text>link_</xsl:text>
<xsl:value-of select="local-name(.)"/>
</xsl:param>
<xsl:variable name="W">
<xsl:choose>
<xsl:when test="$target">
<xsl:value-of select="$target"/>
</xsl:when>
<xsl:when test="contains($dest,'#')">
<xsl:value-of select="substring-after($dest,'#')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$dest"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$dest=''">
<xsl:choose>
<xsl:when test="not($body='')">
<xsl:value-of select="$body"/>
</xsl:when>
<xsl:when test="$ptr='true'">
<xsl:apply-templates mode="xref" select="key('IDS',$W)">
<xsl:with-param name="minimal" select="$minimalCrossRef"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="target">
<xsl:choose>
<xsl:when test="starts-with($dest,'#') or contains($dest,$outputSuffix) or contains($dest,'ID=')">
<xsl:value-of select="$dest"/>
</xsl:when>
<xsl:when test="key('IDS',$W)"/>
<xsl:otherwise>
<xsl:apply-templates mode="generateLink" select="key('IDS',$W)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="linktext">
<xsl:choose>
<xsl:when test="not($body='')">
<xsl:value-of select="$body"/>
</xsl:when>
<xsl:when test="$ptr='true' and count(key('IDS',$W))>0">
<xsl:apply-templates mode="xref" select="key('IDS',$W)">
<xsl:with-param name="minimal" select="$minimalCrossRef"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$ptr='true'">
<xsl:text>??</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$target=''">
<xsl:copy-of select="$linktext"/>
</xsl:when>
<xsl:otherwise>
<a href="{$target}">
<xsl:call-template name="htmlAttributes"/>
<xsl:choose>
<xsl:when test="@rend!=''">
<xsl:attribute name="class">
<xsl:value-of select="@rend"/>
</xsl:attribute>
</xsl:when>
<xsl:when test="@rendition">
<xsl:call-template name="applyRendition"/>
</xsl:when>
<xsl:when test="string-length($class)=0"/>
<xsl:otherwise>
<xsl:attribute name="class">
<xsl:value-of select="$class"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="key('IDS',$W)">
<xsl:choose>
<xsl:when test="starts-with(local-name(.),'div')">
<xsl:attribute name="title">
<xsl:value-of select="translate(normalize-space(tei:head[1]),'><','')"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<xsl:copy-of select="$linktext"/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template> |