[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Language-specific output

Subject: Language-specific output
From: "cavecatem@xxxxxxxxxxxxx" <cavecatem@xxxxxxxxxxxxx>
Date: Wed, 01 Feb 2006 15:31:43
rdf alt
Hi all,

I'm working on a stylesheet that transforms XMP-data to a nicely layouted HTML
file.
I'm working with oxygen and saxon8b (i.e. XSLT 2.0).
Unfortunately, there is the problem of internationalisation, i.e. we have to
be able to create at least a German an English version of the HTML file.

I'm still new to practicing my XML/XSLT-skills so my problems might simply
arise from lack of practice. I didn't find an answer when looking in the list
archive, though.

Rather than maintain two language versions of the stylesheet, I thought I
could try variables in an external file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
    <xsl:variable name="TFilename">
        <a lang="de">Datei: </a>
        <a lang="en">File: </a>
    </xsl:variable>
    <xsl:variable name="TTitle">
        <a lang="de">XMP Steckbrief der Datei </a>
        <a lang="en">XMP Abstract for the file </a>
    </xsl:variable>
    <xsl:variable name="TExifTitle">
        <a lang="de">EXIF-Daten</a>
        <a lang="en">EXIF-Data</a>
    </xsl:variable>
    <xsl:variable name="TExposureTime">
        <a lang="de">Belichtungszeit [s]</a>
        <a lang="en">Exposure time [s]</a>
    </xsl:variable>

      <xsl:variable name="lightsource">
      <a code="1">
      	<a lang="de">unbekannt</a>
     	 <a lang="en">unknown>/a>
      </a>
    <a code="1">
    	<a lang="de">Tageslicht</a>
    	<a lang="en">Artificial</a>
    <a>
 ...
 </xsl:variable>

 So I call the normal variables
 with <xsl:value-of select="$variablename/a [@lang = $lang] />
 and the complex ones with
 with <xsl:value-of select="$variablename/a [@code = $code]/a [@lang = $lang]
/>


It was a bit tricky to get around the xsl:include/xsl:import problem, as the
stylesheets are modular and my parser insisted that I have to include/import
the external file into all sub-stylesheets which then in turn leads to
problems with precedence.

Three questions actually:

1. Why does the parser insist on me declaring the variables in each separate
stylesheet, when he works on the parent stylesheet where the text variable
stylesheet is incuded as a top-level element?
The same doesn't happen with <xsl:param name=lang> which is only declared in
the top level stylesheet.

2. Someone metionend a while ago that it is better to avoid variables as they
create result tree fragments. Is there a better way to do this?

3. The XMP data sometimes contains language-sepcific data in elements of the
type lang alt, e.g.

        <dc:description>
            <rdf:Alt>
               <rdf:li xml:lang="x-default">Pferde bei der
Bachueberquerung</rdf:li>
               <rdf:li xml:lang="en">Horses crossing a stream</rdf:li>
            </rdf:Alt>

Is there a way to get either my specified language or - if that is not present
- the 'language' x-default?

 The following works but doing this for a lot of elements makes it rather
slow.
($lang is passed as a global parameter when saxon is called)

                   <xsl:choose>
                        <xsl:when
test="rdf:Description/dc:rights/rdf:Alt/rdf:li/@xml:lang = $lang">
                            <xsl:value-of
select="rdf:Description/dc:rights/rdf:Alt/rdf:li[@xml:lang = $lang]"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of
select="rdf:Description/dc:rights/rdf:Alt/rdf:li[@xml:lang
                                = 'x-default']"/>
                            </xsl:otherwise>
                    </xsl:choose>


Thanks for any suggestions that might help.

Regards
CJ

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.