简体   繁体   中英

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
  • XSL
  • XSL-FO
  • Saxon
  • other stuff...

And in my XSL-FO file I need to have a presentation slide containing numbered list of specific items. 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

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

This online site can help you to find solution for me, to test it online: 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; in each fo:list-item-label .

You can generate the numbers from the structure of your source XML by using xsl:number . See https://www.w3.org/TR/xslt#number for the XSLT 1.0 definition and some simple examples.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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