This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to select elements based on the value(s) of a multi-valued attribute?


Hi everybody,

Can somebody help me to solve the following problem?
A resource can be translated into more languages
(and multiple times in the same language) and every
translation in that language is applicable for one or
more countries. This is because if one language is
spoken in more countries, some resources are translated
once i.e. the translations for the word "Name" but the
text on the homepage is translated more times in the same
language but each translation is appropiate for another country.


xml:

<resource name="hello">
  <translation>
    <language>fr</language>
    <country>be</country>
    <country>fr</country>
    <!-- translation in french for france and belgium -->
    <text>Bonjour</text>
  </translation>
  <translation>
    <language>nl</language>
    <country>be</country>
    <!-- translation in dutch for belgium -->
    <text>Goedendag</text>
  </translation>
  <translation>
    <language>nl</language>
    <country>nl</country>
    <!-- translation in dutch for the netherlands -->
    <text>Hallo</text>
  </translation>
  <translation>
    <language>en</language>
    <country>nl</country>
    <country>be</country>
    <!-- translation in english for the netherlands and belgium -->
    <text>Hello</text>
  </translation>
  <translation>
    <language>en</language>
    <country>fr</country>
    <!-- translation in english for france -->
    <text>Bon Hello (just an example)</text>
  </translation>
</resource>

xslt:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" indent="yes"/>
<xsl:param name="country"  select="'nl'" />
<xsl:param name="language" select="'nl'" />
<xsl:template match="//resource">
  <xsl:apply-templates select="translation[language=$language and
country=$country]"/>
</xsl:template>
<xsl:template match="//translation">
  <xsl:apply-templates select="text"/>
</xsl:template>
</xsl:stylesheet>

This works :-) Changing the 2 parameters also works :-)
(they are in the future passed to the stylesheet processor, already tested
with MSXML and it worked,
now it are just defaults if nothing is passed)

BUT I don't like the XML syntax...

I want this XML as input and I need an XSLT with the same result as above:
(not that this is also possible: country="be,fr,en,de" and even in some
cases
language="nl,fr,en" or something like that, I would like it if country="be,
nl, fr"
would be possible...)

xml:

<resource name="hello">
  <translation language="fr" country="be,fr">Bonjour</translation>
  <translation language="nl" country="be">Goedendag</translation>
  <translation language="nl" country="nl">Hallo</translation>
  <translation language="en" country="nl, be">Hello</translation>
  <translation language="en" country="fr">Bon Hello (just an
example)</translation>
</resource>

xslt:

????

Can anybody help me out?

Thanks in advance,

Rogier Hofboer



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]