Re: [xsl] XPath to select based on attr = same attr of an ancestor

Subject: Re: [xsl] XPath to select based on attr = same attr of an ancestor
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 13 Jul 2008 23:05:04 -0400
Sorry, Syd, I didn't complete my thought in enough detail.

At 2008-07-13 22:56 -0400, I wrote:
I've also included a solution that uses xml:lang= instead of lang= since there are more semantics for xml:lang= ... for example, in the third test the xml:lang= of the document is a subset of the xml:lang= of the embedded content. I don't know if this will be of help or not (in fact, it might be backwards from what you need and not of any use).

XSLT has the lang(arg) function that returns true() if the inherited xml:lang= language of the current node is a *case-insensitive subset* of the language specified in the argument. So, in my example data in test 3 the xml:lang="FR-CA" matches xml:lang="fr". I'm passing the closest ancestral language attribute to the function that acts on the language of the current node:


match="foreign[lang(ancestor::*[@xml:lang][1]/@xml:lang)]"

... which will be true if there is no xml:lang= on the element, or the tested value if there is an xml:lang= on the element.

I hope this helps.

. . . . . . . . . Ken

--
Upcoming XSLT/XSL-FO hands-on courses:      Wellington, NZ 2009-01
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