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

Re: Re: element in most preferred language expression?

Subject: Re: Re: element in most preferred language expression?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 27 May 2008 18:27:46 -0400
Re:  Re: element in most preferred language expression?
Jack,

At 04:46 PM 5/27/2008, you wrote:
> 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.

Hm, do I get a feeling the goalposts are being moved on us?


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

In XPath 1.0:


title[lang($preferredLanguage)] | title[lang($2ndPreferredLanguage)][not(title[lang($preferredLanguage)])]

This returns the union set of titles with the preferred language and titles with the second preferred language when there are no titles of the preferred language. (You could take the first of this set if you wanted to be sure you'd never have more than one of whichever of these you had.)

In XPath 2.0:

(title[lang($preferredLanguage)], title[lang($2ndPreferredLanguage)])[1]

This returns the first of the sequence of titles with the preferred language followed by titles with the second preferred langage.

Cheers,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

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.