[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] element in most preferred language expression?
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
|
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
|