1

We use the DocBook XSLTs to convert CALS tables to HTML for Web output. Some of our CALS tables contain HTML markup, specifically lists. I'm not sure if this is normal, but our print (PDF) formatting engine - which gets the CALS tables as input - handles it.

However, when the CALS tables are transformed HTML, the list markup with tags are rendered to strings, and the list nesting is preserved in spans (weird!).

Update: I suspect I must be doing something wrong in my application of the DocBook XSLTs, which is intended to convert tables while simply copying all other content from a mixed content-type document. Here is a reproducible example:

CALS input:

  <section>
    <table>
      <tgroup cols="1">
        <colspec colname="col1"/>
        <tbody>
          <row>
            <entry>
              <ol list-style-type="lower-alpha" period-paren="paren">
                <li>This is a nested list:<ol list-style-type="number" period-paren="paren">
                  <li>I'm a list item.</li>
                  <li>I'm another list item!</li>
                </ol></li>
                <li>Yet another nested list:<ol list-style-type="number" period-paren="paren">
                  <li>YALI</li>
                  <li>YAYALI</li>
                </ol></li>
              </ol>
            </entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  </section>

XSLT:

<xsl:stylesheet version="2.0"
                xmlns:html="http://www.w3.org/1999/xhtml"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:import href="docbook-xsl-1.75.2/xhtml/docbook.xsl"/>

  <xsl:template match="/ | /*">
    <xsl:apply-templates mode="initial"/>
  </xsl:template>

  <xsl:template match="table" mode="initial">
    <xsl:apply-templates select="." mode="#default"/>
  </xsl:template>

  <xsl:template match="@*|node()" mode="initial">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" mode="#current"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

Output:

<section><div class="table" xmlns="http://www.w3.org/1999/xhtml">
  <a id="n5dd3b973684deaa" xmlns:saxon="http://icl.com/saxon"></a><p class="title"><b></b></p>
  <div class="table-contents">
    <table border="1"><tbody><tr><td>
    <span style="color: red">&lt;ol&gt;
      <span style="color: red">&lt;li&gt;This is a nested list:<span style="color: red">&lt;ol&gt;
        <span style="color: red">&lt;li&gt;I'm a list item.&lt;/li&gt;</span>
        <span style="color: red">&lt;li&gt;I'm another list item!&lt;/li&gt;</span>
      &lt;/ol&gt;</span>&lt;/li&gt;</span>
      <span style="color: red">&lt;li&gt;Yet another nested list:<span style="color: red">&lt;ol&gt;
        <span style="color: red">&lt;li&gt;YALI&lt;/li&gt;</span>
        <span style="color: red">&lt;li&gt;YAYALI&lt;/li&gt;</span>
      &lt;/ol&gt;</span>&lt;/li&gt;</span>
    &lt;/ol&gt;</span>
    </td></tr></tbody></table>
  </div></div>
<br class="table-break" xmlns="http://www.w3.org/1999/xhtml"/>
</section>
wst
  • 11,681
  • 1
  • 24
  • 39
  • `` seems to be tipping off that the renderer found a node that it was not prepared to see and converts the source code to red text in order to help debugging when you look at the rendered output. That the nesting is preserved is not strange at all. – Tomalak Oct 30 '18 at 17:13
  • 1
    Without seeing the XSLT code that produces this output it's hard to tell what to do to make those nodes "recognized" (my gut feeling would be "write a template for them"). – Tomalak Oct 30 '18 at 17:14
  • @Tomalak These are the stylesheets: https://github.com/docbook/xslt10-stylesheets/releases. Because its such a big library I am wary of trying to override for this and I was hoping there is an official way to get the behavior I want (since this seems so odd). – wst Oct 30 '18 at 18:43
  • I don't have much experience with docbook beyond understanding the fundamentals (and being on all-right terms with XSLT itself), so my general strategy would be to identify the spot in the code base that creates this `class="UNRECOGNIZED"` attribute and work outwards to understand why it appears. – Tomalak Oct 30 '18 at 18:57
  • Do the DocBook XML documents or fragments have a namespace? You haven't shown any in your snippet. I tried to run a simple example with your initial fragment but with the docbook namespace added yesterday in oXygen and it indeed gave the escaped output you have shown but oXygen also indicated several warning emitted by the XSLT processor and `xsl:message` that unknown elements like `ol` or `li` had been encountered. – Martin Honnen Nov 01 '18 at 10:33
  • As the template doing that is in a stylesheet `profile-docbook.xsl` in the `xsl\html` directory of oXygen's DocBook framework installation and the first line of that stylesheet furthermore indicated that stylesheet was generated I didn't dig further. But you might want to ensure you run your XSLT processor so you see any `xsl:message`s and then go from there. – Martin Honnen Nov 01 '18 at 10:35
  • Thanks @MartinHonnen. I found an acceptable solution, but I didn't solve the mystery. – wst Nov 01 '18 at 18:49

1 Answers1

0

Although I was not able to determine the reason for the escaped markup, the HTML markup can be overridden simply, with a higher priority template in the main XSLT:

<xsl:template match="ol" mode="#all">
  <xsl:copy-of select="."/>
</xsl:template>
wst
  • 11,681
  • 1
  • 24
  • 39