XsltFaqMar05

From W3C Wiki


HOW TO EDIT THIS PAGE:

The whole text of the FAQ is here, paragraph by paragraph, with relevant comments sandwiched between. Each point made begins with the initials of the author and date (see below), and continues until the next author's initials or the next quote from the FAQ. Multiple points by the same author on the same piece of text are preceded by multiple initials and separated by "===". Related comments, and replies are grouped together were possible.

The text of the actual article is in bold.

The original bulk of text contains no dates. If adding comments from now on, please use a new paragraph and start the first paragraph in your comment with your initials, followed by the date in square brackets, following the form [RI 2feb].

File names should be 'geo'+date(eg. 0503)+shortMeaningfullName, eg. geo0503linkElement


DRAFT FAQ: XSLT FOR MULTILINGUAL OUTPUT

Question

How do I output multilingual documents from XSLT where different information is required for different languages where there is essentially have the same look & feel?

Background

You output web resources for multilingual web resources where the output is essentially the same in terms of: - Page layout for HTML or document structure for RSS. - Vocabulary, eg, 'latest news' in whatever language. - Language information, ie, each page should have appropriate language tags, eg x for x language. - Character encoding information, ie, each page should have appropriate encoding, eg x for x language.

You might want to change some of this information, eg: - Vocabulary: 'latest news' in whatever language becomes 'news: up to the minute' or a form disclaimer. - Encoding: x encoding to utf-8.

You might consider hard-coding this information into the XSLT, which could involve many switches, eg with <xsl:choose><xsl:when>, etc.

Problems: - You are not separating concerns in terms of presentation & business logic, which is proven, good software engineering practice. - Your XSLT will be overly bloated with output-specific information, making it difficult to focus on the script. - XSLT expertise is required for what is essentially a text-editing change. - Lack of knowledge in editing the XSLT could create problems, eg, preventing users of an XSLT-driven CPMS system from producing pages.

Answer

Use a separate XML 'config' to specify language-specific information, such as: - Character encoding - Language tag - Vocabulary

Ensure that the XML config is well-formed &/or valided against a schema/DTD before made operational.

If there is language-specific data in the XML config ensure that: - The XML encoding value is the same as the encoding used for the web output of that language, [add example]. - The file is saved appropriately, eg, if using utf-8 encoding, save the file as utf-8, otherwise save the file as ASCII.

By the way

You could also provide the XML config information in the XML file containing the new page information. If working with the database, this information could be stored there. However, regarding updating that information, you could incur a similar problem to hard-coding it into the XSLT, ie, a requirement for database knowledge in order to update that information.

Further reading

[to be added]