Subject: Re: [xsl] Find elements where any attribute contains alpha-numerical chars of an input string From: Liam R E Quin <liam@xxxxxx> Date: Sat, 03 Nov 2012 00:10:05 +0100 |
On Fri, 2012-11-02 at 23:54 +0100, Philipp Kursawe wrote: > I would like to select any element whose attributes contain parts of > the input string, stripped by non-alpha chars and whitespace. One way might be to build up a sequence of each run of consecutive alphanumeric characters from $input, and find atttributes that match each such run in turn. //@*[contains(., "sock")] will find all attributes containing "sock", including "hassocks". I'm not sure if that's what you want, or if you only want whole word matches. So, if $input is "dry sock" it should match attributes containing the string "dry" or the string "sock", or both - e.g. <pew items="sundry hassocks" /> You also don't say if it's XPath 1, 2 or 3, and if it's inside XSLT or not. It makes quite a difference. If you're using libxml2, it's XPath 1. If you're using Saxon 8 or later, it's XPath 2. If you're using Gravel 1.2, it's actually a garden path and not XPath at all :-) Liam -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org freenode/#xml Co-author, 5th edition of "Beginning XML", Wrox, July 2012
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Find elements where any attri, Philipp Kursawe | Thread | Re: [xsl] Find elements where any a, Graydon |
[xsl] Find elements where any attri, Philipp Kursawe | Date | Re: [xsl] Find elements where any a, Graydon |
Month |