xsl-list
[Top] [All Lists]

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

2011-04-15 13:23:20
-----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 can’t put the || in an XPath, but
if you’re 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.

~Chris
- -- 
Chris Maden, text nerd  <URL: http://crism.maden.org/ >
“Those in power write the history, while those who suffer
 write the songs.” — Frank Harte
GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 0077 C319
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2ojPgACgkQGfhmdwB3wxnC8QCbBzuYPuXyOLoqjDHCDpmaC50m
6qYAn2V9Gw/8tzQ1yZtMJ7JtimKRcyCV
=wO+l
-----END PGP SIGNATURE-----

--~------------------------------------------------------------------
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>
--~--