<xsl:variable name="targets" select="key('id',@linkend)"/>
<xsl:variable name="footnote" select="$targets[1]"/>
+ <xsl:if test="not(local-name($footnote) = 'footnote')">
+ <xsl:message terminate="yes">
+ERROR: A footnoteref element has a linkend that points to an element that is not a footnote.
+Typically this happens when an id attribute is accidentally applied to the child of a footnote element.
+target element: <xsl:value-of select="local-name($footnote)"/>
+linkend/id: <xsl:value-of select="@linkend"/>
+ </xsl:message>
+ </xsl:if>
+
<xsl:variable name="target.href">
<xsl:call-template name="href.target">
<xsl:with-param name="object" select="$footnote"/>