Menu

#1392 HTML: `<glossterm>` link to `<glossentry>` produces invalid nested `<a>` tag

output: HTML
open
nobody
None
5
2016-12-12
2016-12-12
No

I have recently decided to add glossary section in my book, and it seems to works without problem. But after few tweaks, I found that when the book use <glossterm linkend="..."> to link to a <glossentry> tag: the generated HTML pages will fail W3C validation.

These validation errors persist despite the presence of make.valid.html=1 XSL parameter.

DocBook XML:

<para>
    This is an article with reference to <glossterm linkend="lemon">lemon</glossterm>
    glossary term.
</para>

Note that lemon is an ID of a <glossentry> tag.

HTML:

<p>
        This is an article with reference to <a class="glossterm" href="#lemon"><em class="glossterm"><a class="glossterm" href="#lemon" title="Lemon">lemon</a></em></a>
        glossary term.
    </p>

You would see that there is a duplicate nested <a> tag (linking to the same anchor), which is invalid under HTML 4.01; this affects both single-page and multi-page HTML generation.

While this seems to be a minor issue and likely to be harmless (the link is still clickable and leads to a correct location), it is annoying when one need to make sure that output documents are valid HTML pages.

Test DocBook XML article file which exhibits the problem, together with build script, build log, and affected HTML output are attached as glostermlink-double-a.zip.

DocBook XML DTD: 4.2
DocBook XSL: 1.79.1
XSLT Processor: XSLTproc 1.1.28
Runtime: Cygwin 1.7.28 32-bit
System: Microsoft Windows XP Professional SP3

1 Attachments

Discussion

  • Nutchanon Wetchasit

    I have looked in DocBook 1.79.1 distribution's html/inline.xsl, template glossterm:

    It seemed that inline.italicseq template already generated <a> tag for the <glossterm linkend="..."> link; so the parent <a> tag generation- which is triggered by a presence of linkend attribute of <glossterm>, could be considered redundant.

    The attached experimental patch html-glossterm-remove-nested-link.patch removes the parent <a> tag generation within the code of glossterm template.

    I'm not sure if this is a proper way to fix the issue though.

    Side note: I have yet to check whether XHTML stylesheet has the same problem or not; this patch fixes only HTML stylesheet.

    DocBook XML DTD: 4.2
    DocBook XSL: 1.79.1 (patched against release tarball)
    XSLT Processor: XSLTproc 1.1.28
    Runtime: Cygwin 1.7.28 32-bit
    System: Microsoft Windows XP Professional SP3

     

    Last edit: Nutchanon Wetchasit 2016-12-12
  • Nutchanon Wetchasit

    HTML4-validated test rendering of glosstermlink.xml using the patched stylesheet is attached as glosstermlink-double-a.patched1.html.zip.

    DocBook XML DTD: 4.2
    DocBook XSL: 1.79.1 (patched against release tarball)
    XSLT Processor: XSLTproc 1.1.28
    Runtime: Cygwin 1.7.28 32-bit
    System: Microsoft Windows XP Professional SP3

     
MongoDB Logo MongoDB