[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|