Subject: Re: [xsl] Re: XPath to select node according to xml:lang attribute From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Fri, 15 Apr 2011 18:37:06 -0400 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 04/15/2011 02:18 PM, Philipp Kursawe wrote:Hmm I cannot use XSLT in my context. I can only use XPath. So I guess I would have to select "en-us" first and see if there is a result, if not select "en" and so on. Or could I "||" chain multiple XPath selects? //text[@id='color' and lang('en-us')] || //text[@id='color' and lang('en')] || //text[@id='color']
Not sure what your context is... You canbt put the || in an XPath, but if youbre in some procedural language like Perl or Java, then yes. Pseudocode:
color_label = select( "//text[@id='color' and lang('en-us')]" ) || select( "//text[@id='color' and lang('en')]" ) || select( "//text[@id='color']" )
That would (presuming normal behavior of logical or) get the best match for you.
//text[@id='color' and lang('en-us')] | //text[@id='color' and lang('en')] | //text[@id='color']
//text[@id='color'][ @xml:lang='en-us' or (@xml:lang='en' and not(../@xml:lang='en-us') or not(../@xml:lang='en-us' or../@xml:lang='en')] ]
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re: XPath to select node , Christopher R. Maden | Thread | Re: [xsl] Re: XPath to select node , Philipp Kursawe |
RE: [xsl] Traverse sub tree startin, Graeme Kidd | Date | Re: [xsl] Re: XPath to select node , Philipp Kursawe |
Month |