|
|||||||||
|
Using Separate Documents
You can push this kind of structural efficiency even farther, if you like, by separating each disparate language section in your original XML document, into standalone documents instead. Listing 5 shows this ultimate separation solution for our example. Each
Listing 5. Separating each language into its own document.
Listing 6 utilizes these language-specific XML documents from Listing 5 and produces the resume in localized XHTML format. Listing 6. XSL stylesheet to produce the localized language version from separate XML documents.
This stylesheet contains a template that handles the document root element ("/"). The separate CV documents have names like cv-lang.xml. E.g. cv-en.xml and cv-ja.xml. The stylesheet variable cvData is initialized with the document name and the document is loaded using XSLT document() function. The rest of the stylesheet is basically the same as in Listing 4. As we have seen there are a lot of options for organizing multilingual content. Each document structure has its pros and cons. The content-oriented structure is good when you have stable set of languages you need to support. It is easier to keep language variants synchronized in this structure. The drawback is more complex transformation. Language-oriented structure is strong when you expect the number of supported languages to grow. However, it is more difficult to keep all language versions synchronized. This article should help you decide which will work better for your localization needs, and help you format your XML properly to suit those conditions.
|
|||||||||
Ilari Aarnio is a software architect in Codesys, providing consulting on J2EE, XML technologies and enterprise application integration. Before founding Codesys in 2002, Ilari spent 12 years in various software development and application integration positions, where he developed practical insights into the fundamental issues of software architectures and system solutions. Reach him by e-mail .
| |||||||||
|