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

Re: element in most preferred language expression?

Subject: Re: element in most preferred language expression?
From: Jack Bates <ms419@xxxxxxxxxxxxxx>
Date: Tue, 27 May 2008 13:46:37 -0700
 Re: element in most preferred language expression?
> In addition to Ken's other helpful remarks:
> >>What is the closest XPath expression which could get the value of an
> >>element in a most preferred language?
> >
> >   "title[lang($preferredLanguage)]"

Thank you for pointing out the lang() function, however the heart of my
problem is that an element (<title>) may or may not be available in
$preferredLanguage, in which case I need to fallback to
$2ndPrefferedLanguage, instead of returning empty.

What I am looking for is an XPath expression, suitable for sticking in
the string() function, to get the most preferred non-null element.

The simple case is when there are two languages: $userLanguage and
$sourceLanguage

Let $userLanguage be "fr" (the user prefers to read French) and
$sourceLanguage be "en" (the original language of the data is English)

I need an expression, "string(...an expression for title given
$userLangague=fr and $sourceLanguage=en...)", which when applied to the
following, evaluates to "description archivistique":

<title xml:lang="en">archival description</title>
<title xml:lang="fr">description archivistique</title>
<title xml:lang="pt">descriC'C#o arquivC-stica</title>

- but when applied to the following, evaluates to "information object":

<title xml:lang="en">information object</title>
<title xml:lang="pt">objeto informacional</title>

The more complicated case is when there is a weighted list of language
preferences, as in the HTTP Accept-Language request header - however I
hope that this simple case with generalize.

Thanks again, Jack

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.