xsl-list
[Top] [All Lists]

[xsl] Re: XPath to select node according to xml:lang attribute

2011-04-15 12:53:37
Well I do have a question to that still:

<root>
<text id="color" xml:lang="en">colour</text>
<text id="color" xml:lang="en-us">color</text>
</root>

using //text[@id='color' and (lang('en-us') or lang('en')]/text() will
always return "colour" although I am expecting "color". I know
attributes are not ordered, but can you not have the perfect match be
in the selected result first?

Thanks,
Phil

On Fri, Apr 15, 2011 at 6:42 PM, Philipp Kursawe 
<phil(_dot_)kursawe(_at_)gmail(_dot_)com> wrote:
Ah sorry, nevermind. Just discovered the lang() XPath function :)

Cheers,
Phil

On Fri, Apr 15, 2011 at 6:35 PM, Philipp Kursawe 
<phil(_dot_)kursawe(_at_)gmail(_dot_)com> wrote:
Hello,

Is there a way to select the most specific node for a set of
languages/sub-languages in XPath 1.0 prefered?

<root>
<text id="color" xml:lang="en">colour</text>
<text id="color" xml:lang="en-us">color</text>
</root>

I would like selectSingleNode for "en-us", "en" and as last resort
where no xml:lang tag is specified.
My try was:
/[@id="color" and (@xml:lang="en-us" or @xml:lang="en" or not(@xml:lang))]
but that does not seem to work.

I such finer grained selection possible?

Thanks,
Phil



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--