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 [(_at_)lang = $lang] />
and the complex ones with
with <xsl:value-of select="$variablename/a [(_at_)code = $code]/a [(_at_)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[(_at_)xml:lang = $lang]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="rdf:Description/dc:rights/rdf:Alt/rdf:li[(_at_)xml:lang
= 'x-default']"/>
</xsl:otherwise>
</xsl:choose>
Thanks for any suggestions that might help.
Regards
CJ
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--