Subject: Re: [xsl] element in most preferred language expression? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 12 May 2008 21:29:10 -0400 |
For the most part, everything we could want from our API can be expressed in XPath. One challenge I am facing is multilingual data.
Many of our object's properties may be translated into foreign languages. Happily, I think there is an analogue in XML: the xml:lang attribute.
The HTTP Accept-Language request header contains a list of the user's language preferences and associated weights.
Our API can express the value of a property in a given language. I think the corresponding XPath expression would be something like: ./title[@xml:lang = "fr"]
<title xml:lang="FR">Bonjour!</title> <title xml:lang="fr-ca">Salut!</title>
- the challenge is expressing the value of a property in the most preferred language. I can do this in code, by iterating over the user's language preferences, getting the property value in each language until I get a non-empty node set. However I would like to capture this behaviour behind our API. Ideally a developer could express the value of a property in the user's most preferred language in a single expression. Furthermore, this expression could be combined with other expressions, to get for example, the titles of all an object's children, in the user's most preferred language.
What is the closest XPath expression which could get the value of an element in a most preferred language?
What advice do you have for how to express this in our API?
-- World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] element in most preferred lan, Jack Bates | Thread | Re: [xsl] element in most preferred, Wendell Piez |
[xsl] element in most preferred lan, Jack Bates | Date | Re: [xsl] Page break help, G. Ken Holman |
Month |