idref — Extract IDREF from a linking element
The idref
template accepts
any xref
or universally linking element as a parameter
and returns the local
ID that it points to.
If it has a linkend
attribute,
it returns that value.
If it has a xlink:href
, it
returns that value, parsed as needed to extract just
the id reference. Otherwise it returns an empty string.
<xsl:template name="idref"> <xsl:param name="xref" select="."></xsl:param> <xsl:param name="linkend" select="$xref/@linkend"></xsl:param> <xsl:param name="xpointer"> <xsl:call-template name="xpointer.idref"> <xsl:with-param name="xpointer" select="$xref/@xlink:href"></xsl:with-param> </xsl:call-template> </xsl:param> <xsl:choose> <xsl:when test="string-length($linkend) != 0"> <xsl:value-of select="$linkend"></xsl:value-of> </xsl:when> <xsl:when test="string-length($xpointer) != 0"> <xsl:value-of select="$xpointer"></xsl:value-of> </xsl:when> <!-- otherwise it's a pointer to some other document --> </xsl:choose> </xsl:template>