Pages: 1
Print
Author Topic: Modifying bullet symbols for nested unordered lists in PDF output  (Read 3991 times)
Chris
Solutions Consultant (XMetaL)
Member

Posts: 18


« on: September 10, 2009, 12:08:22 PM »

Let's say you want this:

• foo
• bar
  • foo
  • bar
    • foo
    • bar
    • baz
  • baz
• baz

To look like this:

• foo
• bar
  + foo
  + bar
    * foo
    * bar
    * baz
  + baz
• baz


To modify the bullets for nested unordered lists in PDF output, you 'll need to add a list template and a few variables.

The list template will match on nested unordered lists (not mixed ordered / unordered lists). The variables are used by the the DITA Open toolkit to specify the bullet for a given list.

Add this template to your customization:
[DITA_OT]/demo/xmfo/Customization/fo/xsl/custom.xsl

<!-- Process nested ul lists (not mixed ul / ol lists) -->
<xsl:template match="*[contains(@class, ' topic/ul ')]/*[contains(@class, ' topic/li ')][not(ancestor::*[contains(@class, ' topic/ol ')])]">
<xsl:variable name="listLevel">
    <xsl:value-of select="count(ancestor::*[contains(@class, ' topic/ul ')]) mod 3"/>
</xsl:variable>
<xsl:variable name="bulletVar">
    <xsl:choose>
   <xsl:when test="$listLevel = 1">
       <xsl:text>Unordered List bullet</xsl:text>
   </xsl:when>
   <xsl:when test="$listLevel = 2">
       <xsl:text>Unordered List bullet L2</xsl:text>
   </xsl:when>
   <xsl:when test="$listLevel = 0">
       <xsl:text>Unordered List bullet L3</xsl:text>
   </xsl:when>
    </xsl:choose>
</xsl:variable>
<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 id="{@id}"/>
       <xsl:call-template name="insertVariable">
      <xsl:with-param name="theVariableID" select="$bulletVar"/>
       </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>

Add these variables to [DITA_OT]/demo/xmfo/cfg/common/vars/en_US.xml:

<!-- Extra list bullets for nested unordered lists -->
   
<!-- 2nd level unordered list bullet   + -->
<variable id="Unordered List bullet L2">+</variable>
   
<!-- 3rd level unordered list bullet  * -->
<variable id="Unordered List bullet L3">*</variable>

Notes:
1. Make sure the bullet characters you add can be displayed by the font you use.
A good resource:
http://www.fileformat.info/info/unicode/char/2022/fontsupport.htm

2. You will need to add the extra bullet variables to each language variable file used; e.g. fr_FR.xml, es_ES.xml, etc.

3. XMetaL 5.5 and up may place the DITA OT in you user directory; see DITA Open Toolkit "Deployment" in XMetaL Author Enterprise 5.5:

http://forums.xmetal.com/index.php/topic,237.0.html


HTH,

- Chris

« Last Edit: September 10, 2009, 12:13:40 PM by Chris » Logged

Chris Johnson
XMetaL Services
bzebian
Member

Posts: 27


« Reply #1 on: April 14, 2010, 09:55:17 AM »

I found this works fine for lists in concepts or <context>, but lists within tables or <info> tags revert to normal bullets.
Logged
Pages: 1
Print
Jump to: