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

How to select elements based on the value(s) of a mult

Subject: How to select elements based on the value(s) of a multi-valued attribute?
From: "Rogier Hofboer" <hofboer@xxxxxxxxx>
Date: Mon, 28 Jan 2002 17:04:45 +0100
country.xml
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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-2013 All Rights Reserved.