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] language-specific text alignment

thank you for your response~

it seems that i inherited docbook stylesheets /with/ customization layers

    <property name="html.xsl"       location="${styles.dir}/html/tmaxbook.xsl"/>
    <property name="fo.xsl"         location="${styles.dir}/fo/tmaxbook.xsl"/>

the tmaxbook.xsl files currently do only imports (no templates definitions, parameters settings or variable initializations).

per your instructions i declared and set the document.lang global variable (in tmaxbook.xsl) and then modified the root.properties attribute-set (in param.xsl); however, i get "[java] [error] Element must only be used within a template body;" on the <xsl:choose> line.

within which template should i use this choose/when/otherwise logic? and pardon if i've missed something. i'm a  DocBook/XSLT pre-newbie. the flipside is that here at my company, compared to everyone else, i'm a DocBook expert ^^

any input would be appreciated.
(RE: http://markmail.org/thread/pbouy4dmj67cdtye)

On Fri, Oct 9, 2009 at 1:36 AM, Bob Stayton <bobs@sagehill.net> wrote:
Hi Susan,
There are a couple of ways to accomplish this. All require creating and using a customization layer for the stylesheet, a process described here:


If you have just a few differences based on language, you can integrate the choices into a single customization layer and use xsl:choose to automatically set attribute values based on the lang or xml:lang attribute on the document's root element.

If you have lots of languages and many differences, then an alternative method is to create separate customization layers for each language, and manually select one based on the document's language.

With either method in FO output, you will most likely be modifying properties in the attribute-set named 'root.properties', as those attributes are applied to the whole document (inheritable properties only).

With the first method, you should first employ the utility template named 'l10n.language' to set a global variable to store the value of the root element's lang attribute, like this:

<xsl:variable name="document.lang">
    <xsl:call-template name="l10n.language"/>

For example, if a document starts with <book xml:lang="ja">, then the $document.lang variable will be set to "ja". To make this a global variable, this definition must be outside of any xsl:template in your customization layer.

Then you can modify properties in the root.properties attribute set as follows:

<xsl:attribute-set name="root.properties">
 <xsl:attribute name="text-align">
    <xsl:when test="$document.lang = 'ja'">justify</xsl:when>
 [and other attributes in a similar manner]

If the lang value can be "ja", "ja_JP", "ja-jp", or such, then you should modify the test like this:

 <xsl:when test="starts-with($document.lang, 'ja')">

String matches are case sensitive, so if some documents use lang="JA", you will first have to convert the value to lowercase.  There are a couple of utility templates to do so, described in:


Hope this helps.

Bob Stayton
Sagehill Enterprises

----- Original Message ----- From: "Susan F." <soofalk@gmail.com>
To: <docbook-apps@lists.oasis-open.org>
Sent: Thursday, October 08, 2009 12:05 AM
Subject: [docbook-apps] language-specific text alignment

This is a request for information on how to configure or customize
DocBook to perform language-specific processing. This is not a
question about language-specific text generation, or writing modes.
Desired processing logic is: if lang=jp then alignment=justify,
otherwise alignment=left.

We use XXE as our input tool, DocBook as formatting instructions, and
Apache ANT as our XML -> PDF processor. Our PDFs must be formatted
based on the requirements of their destination country (US, Korea,
China, Japan).

This announcement, http://markmail.org/message/5wo3fy4fk5zwrkdx, says
DocBook 1.74.2 has "support for writing.mode to set text direction and
alignment based on document locale". This seems like what we need. But
further investigation reveals that (a.) I don't know how to identify
the version of DocBook stylesheets I'm using (which I inherited), and
(b.) this support seems to be related only to HTML PI ??

Any suggestions, comments, ideas, solutions will be appreciated.
Thank you,

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]