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

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

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


Subject: Re: [docbook-apps] Customizing substep labels - adding a new numeration?


Hi Bob,

Thank you very much for your help and the detailed explanation. It works really nice :).

If I find some time, I'll do the HTML version as well.

For anyone interested, here is the version I used with my 1.75 stylesheets:

<xsl:template match="orderedlist[not(ancestor::orderedlist)]/
                    listitem/orderedlist/listitem"
             mode="item-number">
 <xsl:variable name="lang">
   <xsl:call-template name="l10n.language"/>
 </xsl:variable>
 <xsl:choose>
   <xsl:when test="$lang = 'ru'">
<xsl:variable name="russian.letters">АБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЫЭЮЯ</xsl:variable>
     <xsl:variable name="number" select="count(preceding-sibling::listitem) + 1"/>
     <xsl:variable name="dividing.character">.</xsl:variable>
<xsl:value-of select="concat(substring($russian.letters, $number, 1),$dividing.character)"/>
   </xsl:when>
   <xsl:otherwise>
     <xsl:apply-imports/>
   </xsl:otherwise>
 </xsl:choose>
</xsl:template>


Robert

On 10/15/2012 05:46 AM, Bob Stayton wrote:

Hi Robert,
Yes, this requires a customization. I assume this is for PDF output. In this
case, I would suggest bypassing most of the templates used for generating the
list numbers.

For FO output, in the file fo/lists.xsl you will find the template with
match="d:orderedlist/d:listitem" is this line that engages the line numbering
machinery:

<xsl:apply-templates select="." mode="item-number"/>

Since this template uses a mode, you can customize the behavior for a specific
element without having to change it for all list items. In your case, you want
to change only a nested listitem. This customization should do what you need:

<xsl:template match="d:orderedlist[not(ancestor::d:orderedlist)]/
d:listitem/d:orderedlist/d:listitem"
mode="item-number">
<xsl:variable name="lang">
<xsl:call-template name="l10n.language"/>
</xsl:variable>

<xsl:choose>
<xsl:when test="$lang = 'ru'">
<xsl:variable name="russian.letters">!@#$%^*()</xsl:variable>
<xsl:variable name="number" select="count(preceding-sibling::listitem) + 1"/>
<xsl:value-of select="substring($russan.letters, $number, 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-imports/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

This template matches only on second level numbered list items. It first calls
the 'l10n.language' template to normalize the locale for DocBook. It sets the
variable $lang from the @xml:lang attribute in the document. However, the value
it returns is not the original @xml:lang value, but the name of the locale file
in the 'common' directory. For Russion, the filename is 'ru.xml', so the $lang
variable here would be set to 'ru' if @lang="RU" or "RU_RU" or any letter case
variant.

Then there is a choose statement, whose xsl:otherwise uses xsl:apply-imports to
fall back the original DocBook templates for non-Russian documents.

For Russian, I set up a variable named 'russian.letters' which should edited to
contain the Russian alphabet. Since I cannot type the Russian alphabet, I
substituted some random symbols in this example.

The $number variable is set to the numeric position of the current listitem,
arrived at by counting the previous siblings and adding 1.

Then it selects the letter based on the numeric position in the alphabet by
using the substring function.

The good thing about this approach is that you have complete control over the
behavior of Russian documents, without needing to understand all the numbering
templates. And you get the default behavior if it is not Russian.

For HTML output, this approach will not work because it does not use any of
those templates used for FO output. HTML output uses <ol> with @type to indicate
numbering, and I don't think @type supports the Russian alphabet. You would have
to switch from <ol> to <dl> and use your own letters in the <dt> element.

Bob Stayton
Sagehill Enterprises
bobs@sagehill.net

--------------------------------------------------
From: "Robert Fekete" <frobert@balabit.com>
Sent: Friday, October 12, 2012 4:07 AM
To: "DocBook Apps" <docbook-apps@lists.oasis-open.org>
Subject: [docbook-apps] Customizing substep labels - adding a new
numeration?

Hi,

I have received a request that requires some stylesheet customization and
I am a bit clueless about how to do it properly.

In some procedures of our docs, we have steps labeled with numbers and
substeps labeled with lowercase letters - that's the Docbook default as
far as I know.
The task would be to label the substeps with Cyrillic letters, but only in
the Russian version of the docs.

I guess I have to customize:

- the common/common.xsl/<xsl:template name="next.numeration"> template to
add a new cyrillic numeration to the list (and somehow test that this
happens only if the language of the root node is Russian)

- and probably the common/labels.xsl/<xsl:template
name="autolabel.format"> template to add an entry for cyrillic numeration

- maybe even common/common.xsl/<xsl:template match="orderedlist/listitem"
mode="item-number">

What I don't see from the stylesheets, is that somewhere I guess I should
provide a list of the cyrillic alphabet, so that the stylesheets know how
to label the steps, but I don't see where or how I could add this.

Is the following process valid, or am I missing something? I'll need this
customization for 1.75.2 and the current 1.77-ns stylesheets as well.

Any help is appreciated.

Kind Regards,

Robert Fekete




---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org








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