docbook / xslTNG

DocBook xslTNG Stylesheets
https://xsltng.docbook.org
MIT License
41 stars 20 forks source link

Error when determining the label for entries in Bibliography #479

Open fsteimke opened 4 months ago

fsteimke commented 4 months ago

I found an issue with the attached source document. Maybe i know how to fix it, but i don't understand the reason for the issue.

xnachweis.zip

The document contains a bibliography. Entries are referenced with citation. Transforming it to HTML with the recent release 2.2.0 shows that citationelements became a links to the biblioentry, which is correct. But I would expect the value of bibliomixed/abbrev as link content., Instead i find a label that is obviously generated by the stylesheets: "R_bi1_bibliomixed1" instead of "EU-TDD".

I am pretty sure that this is caused by the following template which is located at line 147 in xref.xsl:

<xsl:template match="db:bibliomixed|db:biblioentry" mode="m:crossref-label">
  <xsl:choose>
    <xsl:when test="node()[1]/self::db:abbrev
                    or (node()[1]/text()
                        and normalize-space(node()[1]) = ''
                        and node()[2]/self::db:abbrev)">
      <xsl:apply-templates select="db:abbrev[1]"/>
    </xsl:when>
    <xsl:when test="@xml:id">
      <xsl:value-of select="@xml:id"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:next-match/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

The first branch checks, if for a given biblioentry or bibliomixed element one of the following conditions holds:

  1. the first node is an db:abbrev element, or
  2. the first node is a text node which, when normalized, is equal to the empty string, and the second node is an db:abbrev element

This check fails with the bibliomixed elements from the attached document, but i don't understand the reason. Debugging with <xsl:message /> indicates that:

This is what confuses me: the string-length is 0, but it is not equal to the empty string?

However, i think that the first check can be simplified to *[1]/self::db:abbrev (is the first element-node an db:abbrev element?). I will make a pull request with this expression. Test ran successfully at my system.

Greetings, Frank