xsl-list
[Top] [All Lists]

Re: [xsl] Find elements where any attribute contains alpha-numerical chars of an input string

2012-11-02 20:44:26
On Fri, Nov 02, 2012 at 11:54:22PM +0100, Philipp Kursawe scripsit:
I have this rather complex xpath:

//element[@*[contains(translate(., translate(.,
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', ''),
''), translate('string', translate('string',
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', ''),
''))]]

where "string" would be an input string with non-alpha chars and
spaces and mixed letter cases.
I would like to select any element whose attributes contain parts of
the input string, stripped by non-alpha chars and whitespace.

Problem is, the xpath does not work for mixed char input strings.

Wouldn't 

//element[matches(@*,replace($string,'[\p{L}\p{Nd}]',''),'i')]

work?

(I'm really not quite clear what you mean by whitespace above; you don't do
anything with it in your example XPath, so it's unclear to me if you
want to strip the whitespace from the attributes or the provide string.)

-- Graydon

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