Editing indents of lists of level 1+
Posted: Tue Jul 30, 2024 2:07 pm
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.
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.

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>