OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook] Arabic-Indic numbering in XSL FO output for orderedlist

Hi Amin,

You can do this, but you'll need to customize the stylesheets. The critical piece of code is the template that matches "d:orderedlist/d:listitem" in mode="item-number" in the file common/common.xsl (not in the fo directory of the stylesheets).

This template uses the xsl:number function from XSL. While xsl:number uses (to some degree) the current language, it only seems to use it in conjunction with another attribute (format). The DocBook stylesheets only set the format to one of a restricted set (arabic, loweralpha, upperalpha, lowerroman, and upperroman), and does not provide a means to insert a custom value of format. Thus, regardless of which language you set, you will still get arabic (1-9) numerals for the first level of an orderedlist.

However, xsl:number will let you do what you want to do, but you'll need to customize the stylesheets:

The easiest way to do this (which is, without a doubt a real hack), is to customize this template and change the value "1." in the line that tests for $numeration='arabic'" to "١" as shown below:
<xsl:template match="d:orderedlist/d:listitem" mode="item-number">
  <xsl:variable name="type">
      <xsl:when test="$numeration='arabic'">&#x661;</xsl:when> <!-- this is the line -->
      <xsl:when test="$numeration='loweralpha'">a.</xsl:when>
      <xsl:when test="$numeration='lowerroman'">i.</xsl:when>
      <xsl:when test="$numeration='upperalpha'">A.</xsl:when>
      <xsl:when test="$numeration='upperroman'">I.</xsl:when>
      <!-- What!? This should never happen -->

This is a hack, but it will do the job (until you change your xml:lang or nest a list:-). You could also add some logic to only select this value when the locale is "ar" or when you use some parameter, which would be a bit better.

A much better, but much more complex, solution would be to use gentext to select the values associated with arabic, loweralpha, etc., based on locale. The DocBook Definitive Guide for DocBook 5 actually does suggest that the values could be based on locale, though it does not mandate that option.

I'm going to file an RFE on the stylesheets suggesting that the maintainers consider such an addition. It's not clear to me that this is the best thing to do in the general case, because it would change the current behavior for a lot of locales. But, I think it's worth having the discussion.

I hope this helps.
Dick Hamilton
XML Press
XML for Technical Communicators

On Feb 14, 2015, at 20:27, Amin Abbaspour <a.abbaspour@gmail.com> wrote:

> hi everyone,
> how can I use arabic-indic numbering for orderedlist items in FO output of docbook-xsl. 
> I can get it working with epub/html using CSS but not much success with FO. 
> for the record, setting "chapter.autolabel" parameter to '&#x661;' makes Arabic/Persian numbers working in chapters but that’s separate than orderedlist items.
> many thanks for the help,
> Amin

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]