[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: element in most preferred language expression?
At 2008-05-12 17:37 -0700, Jack Bates wrote:
For the most part, everything we could want from our API can be expressed in XPath. One challenge I am facing is multilingual data. And the analogue in XPath: the lang() function The HTTP Accept-Language request header contains a list of the user's language preferences and associated weights. I disagree. That is too literal for xml:lang because if there was a property with xml:lang="fr-ca" (Canadian French) and not one with xml:lang="fr" (French), then you would inappropriately assume there is no French available. There is also the issue of case ... lang() correctly supports a caseless match while your proposal does not. There is also the issue of ancestry ... an ancestor of the element will in fact specify the language of the element when the element doesn't have an xml:lang= attribute. But ... I haven't typically seen lang() used in a predicate and I can see an issue. The XPath expression "title[lang('fr')]" (you don't need the leading "./") would return more than one title if the children of the context element included: <title xml:lang="FR">Bonjour!</title> <title xml:lang="fr-ca">Salut!</title> ... but that XPath expression does return the set of matching titles without having to do an iteration. There is no way to weigh either of these as "closer" to 'fr' than the other when you use the lang() function. So you will have to decide what to do when more than one item is returned for a given language. If you know your data set won't have such ambiguity, then there won't be a problem using lang() as I suggest. - 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. "title[lang($preferredLanguage)]" What advice do you have for how to express this in our API? Sorry ... no suggestions ... I'm focused on the XPath and how I teach the XSLT. I'll let others comment on the API. I hope this helps. . . . . . . . . . . . . Ken -- 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
|
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
|