Re: How to add multiple formats for <li> element in <ul>


Nicolas Delobel
 

Hi Derek,

I think in you case you have to create a new a new attribute set per ul level: ul.ul.li__label, ul.ul.ul.li__label, ul.ul.ul.ul.li__label, etc.

And after, you have to apply dynamically these attibute-set based on item level using processAttrSetReflection named template:
<xsl:template match="*[contains(@class, ' topic/ul ')]/*[contains(@class, ' topic/li ')]">
        <xsl:variable name="depth" select="count(ancestor::*[contains(@class, ' topic/ul ')])"/>
        <xsl:variable name="attrName" as="xs:string">
            <xsl:for-each select="0 to $depth">ul.</xsl:for-each>
        </xsl:variable>
        <fo:list-item xsl:use-attribute-sets="ul.li">
            <xsl:call-template name="commonattributes"/>
            <fo:list-item-label>
                <xsl:call-template name="processAttrSetReflection">
                    <xsl:with-param name="attrSet" select="concat('ul',$attrName,'li__label__content')"/>
                    <xsl:with-param name="path" select="'../../cfg/fo/attrs/commons-attr.xsl'"/>
                </xsl:call-template>
                <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 - 1) mod 4) + 1)"/>
                    </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>
I didn't test, but I think it may work.

Regards,
Nicolas

Join main@dita-users.groups.io to automatically receive all group messages.