<xsl:template match="footnoteref">
<xsl:variable name="footnote" select="key('id',@linkend)"/>
+
+ <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:call-template name="format.footnote.mark">
<xsl:with-param name="mark">
<xsl:apply-templates select="$footnote" mode="footnote.number"/>