Skip to Content
Java and XSLT
book

Java and XSLT

by Eric M. Burke
September 2001
Intermediate to advanced
528 pages
13h 46m
English
O'Reilly Media, Inc.
Content preview from Java and XSLT

Internationalization with XSLT

In this section, we explore the key techniques for internationalization (i18n) using XSLT. Although both Java and XSLT offer excellent support for i18n, pulling everything together into a working application is quite challenging. Hopefully this material will help to minimize some of the common obstacles.

XSLT Stylesheet Design

In its simplest form, i18n is accomplished by providing a separate XSLT stylesheet for each supported language. While this is easy to visualize, it results in far too much duplication of effort. This is because XSLT stylesheets typically contain some degree of programming logic in addition to pure display information. To illustrate this point, directory.xml is presented in Example 8-16. This is a very basic XML datafile that will be transformed using either English or Spanish XSLT stylesheets.

Example 8-16. directory.xml

<?xml version="1.0" encoding="UTF-8"?>
<directory>
  <employee category="manager">
    <name>Joe Smith</name>
    <phone>4-0192</phone>
  </employee>
  <employee category="programmer">
    <name>Sally Jones</name>
    <phone>4-2831</phone>
  </employee>
  <employee category="programmer">
    <name>Roger Clark</name>
    <phone>4-3345</phone>
  </employee>
</directory>

The screen shot shown in Figure 8-6 shows how an XSLT stylesheet transforms this XML into HTML.

And finally, Example 8-17 lists the XSLT stylesheet that produces this output.

English XSLT output

Figure 8-6. English ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning XSLT

Learning XSLT

Michael Fitzgerald
XSLT

XSLT

Doug Tidwell
XSLT and XPATH: A Guide to XML Transformations

XSLT and XPATH: A Guide to XML Transformations

John Robert Gardner, Zarella L. Rendon

Publisher Resources

ISBN: 0596001436Supplemental ContentCatalog PageErrata