如何使用XSL-FO创建有序列表(HTML中的ol)?

时间:2017-05-10 08:21:37

标签: xml xslt pdf-generation xsl-fo saxon

美好的一天,

我正在制作演示文稿,将其从xml转换为pdf,我正在使用这些技术:

  • XML
  • XSL
  • XSL-FO
  • 撒克逊
  • 其他东西......

在我的XSL-FO文件中,我需要一个包含特定项目编号列表的演示文稿幻灯片。我找到的只是本段上面所示的常见列表。以下是列表的xsl-fo文档:https://www.alt-soft.com/tutorial/xslfo_tutorial/xsl-fo_list.html

这是我的代码:

    <fo:list-block padding="4pt" margin-left="10mm" margin-top="4mm">
        <xsl:for-each select="//*[starts-with(name(), 'slide_')]">
            <xsl:if test="not(position()=1)">
                <fo:list-item margin-left="13mm"  margin-top="8mm" margin-right="5mm" font-family="Times, 'Times New Roman', serif" font-size="15pt">
                    <fo:list-item-label end-indent="label-end()">
                        <fo:block>&#x02022;</fo:block>
                    </fo:list-item-label>
                    <fo:list-item-body start-indent="body-start()">
                        <fo:block margin-left="10mm">
                            <xsl:value-of select="title"/>
                        </fo:block>
                    </fo:list-item-body>

                </fo:list-item>
            </xsl:if> 
        </xsl:for-each>
    </fo:list-block>

此代码将生成所有幻灯片标题的公共点列表,但我无法在HTML中创建像ol这样的数字的有序列表。我发现只有这些列表元素以某种方式嵌套的解决方案对我不起作用。我尝试过,但在编译过程中总是失败。以下是该代码的链接(第8,9页):https://www.w3.org/Style/XSL/TestSuite/contrib/FOP/list.pdf

此在线网站可以帮助您为我找到解决方案,在线测试: http://www.utilities-online.info/foprender/#.WRLOAYh97cs

有什么解决方法可以解决这个问题吗?在此先感谢您的回复。

1 个答案:

答案 0 :(得分:1)

您需要在每个&#x02022;中添加一个数字来代替fo:list-item-label

您可以使用xsl:number从源XML结构中生成数字。有关XSLT 1.0定义和一些简单示例,请参阅https://www.w3.org/TR/xslt#number

相关问题