简体   繁体   English

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

[英]How to create an ordered list (ol in HTML) with XSL-FO?

Good day, 美好的一天,

I am working on presentation to convert it to pdf from xml where I am using these technologies: 我正在使用将这些技术从xml转换为xml的pdf的演示文稿:

  • XML XML格式
  • XSL XSL
  • XSL-FO XSL-FO
  • Saxon 撒克逊人
  • other stuff... 其他的东西...

And in my XSL-FO file I need to have a presentation slide containing numbered list of specific items. 在我的XSL-FO文件中,我需要一张演示幻灯片,其中包含特定项目的编号列表。 Only thing I found is only common list as shown above this paragraph. 我发现的唯一内容只是该段上方显示的常见列表。 Here is xsl-fo documentation for lists: https://www.alt-soft.com/tutorial/xslfo_tutorial/xsl-fo_list.html 这是列表的xsl-fo文档: https : //www.alt-soft.com/tutorial/xslfo_tutorial/xsl-fo_list.html

Here is my code: 这是我的代码:

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

This code will generate common dot list of all slide titles, but I am unable to make an ordered list with numbers like ol in HTML. 这段代码将生成所有幻灯片标题的公共点列表,但是我无法使用HTML中的ol这样的数字来创建有序列表。 I found only solution that not work for me where these list elements are somehow nested. 我发现只有嵌套这些列表元素的解决方案对我不起作用。 I tried it but during compilation it always fail. 我尝试过,但是在编译过程中总是失败。 Here is link to that code(page 8,9): https://www.w3.org/Style/XSL/TestSuite/contrib/FOP/list.pdf 这是该代码的链接(第8,9页): https : //www.w3.org/Style/XSL/TestSuite/contrib/FOP/list.pdf

This online site can help you to find solution for me, to test it online: http://www.utilities-online.info/foprender/#.WRLOAYh97cs 该在线站点可以帮助您找到适合我的解决方案,以在线对其进行测试: http : //www.utilities-online.info/foprender/#.WRLOAYh97cs

Is there some solution how this can be done please? 请问有什么解决办法可以做到这一点吗? Thanks in advance for your reply. 预先感谢您的答复。

You need to put a number in place of the &#x02022; 您需要用数字代替&#x02022; in each fo:list-item-label . 在每个fo:list-item-label

You can generate the numbers from the structure of your source XML by using xsl:number . 您可以使用xsl:number从源XML的结构生成数字。 See https://www.w3.org/TR/xslt#number for the XSLT 1.0 definition and some simple examples. 有关XSLT 1.0的定义和一些简单的示例,请参见https://www.w3.org/TR/xslt#number

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM