[xsl] element in most preferred language expression?

Subject: [xsl] element in most preferred language expression?
From: Jack Bates <ms419@xxxxxxxxxxxxxx>
Date: Mon, 12 May 2008 17:37:07 -0700
I am working on an API for an open source records management
application: http://code.google.com/p/qubit-toolkit/

The data in the application consists of hierarchically organized
objects, and object properties. Because of this data's resemblance to
XML (hierarchically organized elements and element attributes), I am
trying to design an API which resembles XPath.

I think the advantages of an API which resembles XPath is that it is
comfortable to developers who are already familiar with XPath, and that
it benefits from XPath's proven good design - hopefully taking advantage
of the experience of the people who designed XPath.

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"]

- 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?

Thanks and best wishes, Jack

Current Thread