1

我们使用 DocBook XSLT 将 CALS 表转换为 HTML 以用于 Web 输出。我们的一些 CALS 表包含 HTML 标记,特别是列表。我不确定这是否正常,但我们的打印 (PDF) 格式化引擎 - 将 CALS 表作为输入 - 处理它。

但是,当 CALS 表转换为 HTML 时,带有标签的列表标记将呈现为字符串,并且列表嵌套保留在跨度中(奇怪!)。

更新:我怀疑我在 DocBook XSLT 的应用程序中一定做错了,它旨在转换表格,同时简单地从混合内容类型的文档中复制所有其他内容。这是一个可重现的示例:

CALS 输入:

  <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>

输出:

<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>
4

1 回答 1

0

虽然我无法确定转义标记的原因,但可以简单地覆盖 HTML 标记,在主 XSLT 中使用更高优先级的模板:

<xsl:template match="ol" mode="#all">
  <xsl:copy-of select="."/>
</xsl:template>
于 2018-11-01T18:47:14.447 回答