Question

Problem: I'd like to switch all nested unordered lists to dashes instead of bullets.

I believe the XPath expression to select these nested list items is: //ul/li/ul//li

I believe this is the appropriate template to modify:

<xsl:template match="*[contains(@class, ' topic/ul ')]/*[contains(@class, ' topic/li ')]">
    <fo:list-item xsl:use-attribute-sets="ul.li">
        <fo:list-item-label xsl:use-attribute-sets="ul.li__label">
            <fo:block xsl:use-attribute-sets="ul.li__label__content">
                <fo:inline>
                    <xsl:call-template name="commonattributes"/>
                </fo:inline>
                <xsl:call-template name="insertVariable">
                    <xsl:with-param name="theVariableID" select="'Unordered List bullet'"/>
                </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>

It's referencing a variable in en.xml named "Unordered List Bullet":

<variable id="Unordered List bullet">&#x2022;</variable>

I've tried wrapping that variable call to reference another variable "Unordered List Dash" if it is nested. I'm still getting a bit hung up. What is the most graceful approach? Should I instead setup an additional template for these nested items?

I'm using DITA-OT 1.5.4.

Was it helpful?

Solution

This list template override formats all unordered list items using dashes when the unordered list is a child of any other list type, including task steps, so you might need to refine the XPath expression in the xsl:when test attribute.

    <xsl:template match="*[contains(@class, ' topic/ul ')]/*[contains(@class, ' topic/li ')]">
    <fo:list-item xsl:use-attribute-sets="ul.li">
      <fo:list-item-label xsl:use-attribute-sets="ul.li__label">
        <fo:block xsl:use-attribute-sets="ul.li__label__content">
          <fo:inline>
            <xsl:call-template name="commonattributes"/>
          </fo:inline>
          <xsl:choose>
            <xsl:when test="ancestor::*[contains(@class, ' topic/li ')]">
              <xsl:call-template name="insertVariable">
                <xsl:with-param name="theVariableID" select="'Unordered List dash'"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="insertVariable">
                <xsl:with-param name="theVariableID" select="'Unordered List bullet'"/>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </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>

And here's the variable from the strings file. <variable id="Unordered List dash">-</variable>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top