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:
http://www.sagehill.net/docbookxsl/CustomMethods.html#CustomizationLayer
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"/>
</xsl:variable>
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:choose>
<xsl:when test="$document.lang = 'ja'">justify</xsl:when>
<xsl:otherwise>start</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
[and other attributes in a similar manner]
</xsl:attribute-set>
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:
http://www.sagehill.net/docbookxsl/ReplaceTemplate.html#UtilityTemplates
Hope this helps.
Bob Stayton
Sagehill Enterprises
[email protected]
----- Original Message -----
From: "Susan F." <[email protected]>
To: <[email protected]>
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,
Susan
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]