Skip to content

Commit 982af20

Browse files
author
Sanders Kleinfeld
committed
Proper href handling for XREF elements.
1 parent 76c6187 commit 982af20

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

htmlbook-xsl/xrefgen.xsl

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,16 @@
1919
<!-- All XREFs must be tagged with a @data-type containing XREF -->
2020
<xsl:template match="h:a[contains(@data-type, 'xref')]">
2121
<xsl:param name="autogenerate-xrefs" select="$autogenerate-xrefs"/>
22-
<xsl:variable name="href-anchor">
23-
<xsl:choose>
24-
<!-- If href contains an # (as it should), we're going to assume the subsequent text is the referent id -->
25-
<xsl:when test="contains(@href, '#')">
26-
<xsl:value-of select="substring-after(@href, '#')"/>
27-
</xsl:when>
28-
<!-- Otherwise, we'll just assume the entire href is the referent id -->
29-
<xsl:otherwise>
30-
<xsl:value-of select="@href"/>
31-
</xsl:otherwise>
32-
</xsl:choose>
22+
<xsl:variable name="calculated-output-href">
23+
<xsl:call-template name="calculate-output-href">
24+
<xsl:with-param name="source-href-value" select="@href"/>
25+
</xsl:call-template>
3326
</xsl:variable>
27+
<xsl:variable name="href-anchor" select="substring-after($calculated-output-href, '#')"/>
3428
<xsl:copy>
35-
<xsl:apply-templates select="@*"/>
36-
<xsl:choose>
29+
<xsl:apply-templates select="@*[not(name(.) = 'href')]"/>
30+
<xsl:attribute name="href" select="$calculated-output-href"/>
31+
<xsl:choose>
3732
<!-- Generate XREF text node if $autogenerate-xrefs is enabled -->
3833
<xsl:when test="$autogenerate-xrefs = 1">
3934
<xsl:choose>

0 commit comments

Comments
 (0)