Ordered list numbers instead of letters for sub-items
Posted: Tue Feb 20, 2018 8:52 pm
Hello all,
Trying to solve this on my own, I found this topic topic14416.html. One difference between that request and mine is (besides wanting to go from letters to numbers) is that I don't necessarily need/want this to be a specific instance only, I would (ideally) like to change this as default behaviour (removing the need for setting an outputclass in the OL).
From that thread, I borrowed/modified the following code:
This seems to work when the outputclass is set, except that I want to nest the higher-level numbering into the lower-level, so that, for example, sub-items under "1" would be "1.1, 1.2, etc." and I'm not sure how to format the numbering here.
Trying to solve this on my own, I found this topic topic14416.html. One difference between that request and mine is (besides wanting to go from letters to numbers) is that I don't necessarily need/want this to be a specific instance only, I would (ideally) like to change this as default behaviour (removing the need for setting an outputclass in the OL).
From that thread, I borrowed/modified the following code:
Code: Select all
<xsl:template match="*[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: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:choose>
<xsl:when test="parent::node()/@outputclass='decimal'">
<xsl:number format="1"/>
</xsl:when>
<xsl:when test="@outputclass='decimal'">
<xsl:number format="1"/>
</xsl:when>
<xsl:otherwise>
<xsl:number/>
</xsl:otherwise>
</xsl:choose>
</number>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</fo:list-item-label>