Editing indents of lists of level 1+

Having trouble installing Oxygen PDF Chemistry? Got a bug to report? Post it all here.
Yuriy_1977
Posts: 10
Joined: Thu Jan 20, 2022 8:05 am

Editing indents of lists of level 1+

Post by Yuriy_1977 »

Hi!
I use:
*.ditamap transformation scenario - "DITA Map PDF - based on XSL-FO"
I want to get different indents for lists of levels 1+ than by default: align the 1+ list's level with the text of the previous list's level (see image below).
For the list's level 1+ I used in custom.xsl templates from the lists.xsl (see code below). So, it will be necessary to write templates for each list's level.
Please, tell me if there is a more compact solution so as not to write a template for each list's level?

Thanks in advance.

Image

Code: Select all

<xsl:template match="*[contains(@class, ' topic/ol ')]/*[contains(@class, ' topic/li ')]/*[contains(@class, ' topic/ul ')]/*[contains(@class, ' topic/li ')]">
        <xsl:variable name="depth" select="count(ancestor::*[contains(@class, ' topic/ul ')])"/>
        <fo:list-item xsl:use-attribute-sets="ul.li">
            <xsl:attribute name="start-indent">12.5mm</xsl:attribute>
            <xsl:attribute name="text-indent">6mm</xsl:attribute>
            <xsl:attribute name="provisional-distance-between-starts">5mm</xsl:attribute>
            <xsl:attribute name="provisional-label-separation">1mm</xsl:attribute>
            <xsl:attribute name="color">blue</xsl:attribute>
            <xsl:call-template name="commonattributes"/>
            <fo:list-item-label xsl:use-attribute-sets="ul.li__label">
                <fo:block xsl:use-attribute-sets="ul.li__label__content">
                    <xsl:call-template name="getVariable">
                        <xsl:with-param name="id" select="concat('Unordered List bullet ', $depth)"/>
                    </xsl:call-template>
                </fo:block>
            </fo:list-item-label>
            <fo:list-item-body xsl:use-attribute-sets="ul.li__body">
                <fo:block xsl:use-attribute-sets="ul.li__content">
                    <xsl:apply-templates/>
                </fo:block>
            </fo:list-item-body>
        </fo:list-item>
    </xsl:template>
    
    <xsl:template match="*[contains(@class, ' topic/ul ')]/*[contains(@class, ' topic/li ')]/*[contains(@class, ' topic/ol ')]/*[contains(@class, ' topic/li ')]">
        <xsl:variable name="depth" select="count(ancestor::*[contains(@class, ' topic/ol ')])"/>
        <xsl:variable name="format">
            <xsl:call-template name="getVariable">
                <xsl:with-param name="id" select="concat('Ordered List Format ', $depth)"/>
            </xsl:call-template>
        </xsl:variable>
        <fo:list-item xsl:use-attribute-sets="ol.li">
            <xsl:attribute name="start-indent">12.5mm</xsl:attribute>
            <xsl:attribute name="text-indent">6mm</xsl:attribute>
            <xsl:attribute name="provisional-distance-between-starts">5mm</xsl:attribute>
            <xsl:attribute name="provisional-label-separation">1mm</xsl:attribute>
            <xsl:attribute name="color">blue</xsl:attribute>
            <xsl:call-template name="commonattributes"/>
            <fo:list-item-label xsl:use-attribute-sets="ol.li__label">
                <fo:block xsl:use-attribute-sets="ol.li__label__content">
                    <xsl:call-template name="getVariable">
                        <xsl:with-param name="id" select="concat('Ordered List Number ', $depth)"/>
                        <xsl:with-param name="params" as="element()*">
                            <number>
                                <xsl:number format="{$format}"/>
                            </number>
                        </xsl:with-param>
                    </xsl:call-template>
                </fo:block>
            </fo:list-item-label>
            <fo:list-item-body xsl:use-attribute-sets="ol.li__body">
                <fo:block xsl:use-attribute-sets="ol.li__content">
                    <xsl:apply-templates/>
                </fo:block>
            </fo:list-item-body>
        </fo:list-item>
    </xsl:template>
  
    <xsl:template match="*[contains(@class, ' topic/ol ')]/*[contains(@class, ' topic/li ')]/*[contains(@class, ' topic/ol ')]/*[contains(@class, ' topic/li ')]">
        <xsl:variable name="depth" select="count(ancestor::*[contains(@class, ' topic/ol ')])"/>
        <xsl:variable name="format">
            <xsl:call-template name="getVariable">
                <xsl:with-param name="id" select="concat('Ordered List Format ', $depth)"/>
            </xsl:call-template>
        </xsl:variable>
        <fo:list-item xsl:use-attribute-sets="ol.li">
            <xsl:attribute name="start-indent">12.5mm</xsl:attribute>
            <xsl:attribute name="text-indent">6mm</xsl:attribute>
            <xsl:attribute name="provisional-distance-between-starts">5mm</xsl:attribute>
            <xsl:attribute name="provisional-label-separation">1mm</xsl:attribute>
            <xsl:attribute name="color">blue</xsl:attribute>
            <xsl:call-template name="commonattributes"/>
            <fo:list-item-label xsl:use-attribute-sets="ol.li__label">
                <fo:block xsl:use-attribute-sets="ol.li__label__content">
                    <xsl:call-template name="getVariable">
                        <xsl:with-param name="id" select="concat('Ordered List Number ', $depth)"/>
                        <xsl:with-param name="params" as="element()*">
                            <number>
                                <xsl:number format="{$format}"/>
                            </number>
                        </xsl:with-param>
                    </xsl:call-template>
                </fo:block>
            </fo:list-item-label>
            <fo:list-item-body xsl:use-attribute-sets="ol.li__body">
                <fo:block xsl:use-attribute-sets="ol.li__content">
                    <xsl:apply-templates/>
                </fo:block>
            </fo:list-item-body>
        </fo:list-item>
    </xsl:template> 
Attachments
Lists example.png
Lists example.png (40.45 KiB) Viewed 347 times
julien_lacour
Posts: 552
Joined: Wed Oct 16, 2019 3:47 pm

Re: Editing indents of lists of level 1+

Post by julien_lacour »

Hello,

You could try something similar to the $depth variable used in org.dita.pdf2/xsl/fo/lists.xsl and set the values dynamically.

Regards,
Julien
Yuriy_1977
Posts: 10
Joined: Thu Jan 20, 2022 8:05 am

Re: Editing indents of lists of level 1+

Post by Yuriy_1977 »

Thanks for the quick response!
I will try.
Post Reply