【问题标题】:Docbook - suppressing TOCDocbook - 抑制 TOC
【发布时间】:2012-07-16 22:05:43
【问题描述】:

我正在使用 1.77 xsl 转换将 docbook 转换为 html。但是当它被转换时,它会自动生成一个目录。你如何改变这种行为?

我发现了这个:Disable table of contents for documents

所以我猜测 html xsl 转换将是表示系统?

【问题讨论】:

    标签: html docbook


    【解决方案1】:

    Elaborate DocBook 格式旨在使用 xsl 样式表进行自定义。

    另见

    Writing a DocBOok Customization Layer for Formatting

    Customizing Table Of Contents Using XSL

    customize_formatting.xsl:DocBook XSL 自定义层示例

    <?xml version="1.0" encoding="UTF-8"?>
    
    <xsl:stylesheet 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:fo="http://www.w3.org/1999/XSL/Format"
        version="1.0"> <!-- change this to 2.0 if your tools support it -->
        <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
    
        <!--uncomment this to suppress toc when using XSL 1.0 or 2.0
        <xsl:param name="generate.toc">article</xsl:param>
        <xsl:param name="generate.toc">book</xsl:param>
        -->
    
        <!--uncomment this to suppress toc when using XSL 2.0
        <xsl:param name="generate.toc">
            article nop
            book nop
        </xsl:param>
        -->
    
    </xsl:stylesheet>
    

    如何使用customize_formatting.xsl

    让您的工具使用customize_formatting.xsl 而不是现成的docbook.xsl。然后,将您的所有格式自定义设置在 &lt;xsl:stylesheet&gt; 部分的正文中。

    对于 TOC 抑制,您可以取消注释相应的行。

    有些(或者可能是全部)XSL 1.0 工具有一个怪癖,似乎阻止它们处理&lt;xsl:param name="generate.toc"&gt; 正文中使用的空格分隔对。我已经成功地通过使用单个单词 articlebook 而不是正确的空格分隔对来抑制 TOC。

    【讨论】:

      【解决方案2】:

      转换时,可以使用Transformer#setParameter(String, Object) 方法指定不生成TOC,如下所示:

      transformer.setParameter("generate.toc", "nop");
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-23
        • 1970-01-01
        相关资源
        最近更新 更多