xsl-list
[Top] [All Lists]

Re: Testing for presence of alphabetical characters

2006-02-06 11:15:12
On 2/6/06, Ian MacDaniel <ian_macdaniel(_at_)yahoo(_dot_)com> wrote:
Using Saxon 851... can someone tell me why the
following expression returns false?
[snip]
<xsl:variable name="alpha"
select="'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:if test="contains($alpha, $cont)">
[/snip]


Errr, I think you are misunderstanding contains (possibly because of
how translate works).  If you read the function description for XPath
2.0 (or XPath 1.0, I don't think it has changed at all) it says the
function contains tests to see if the first string contains the second
string anywhere.  Unless $cont is always a single character or
contains a string in alphabetical order (like bc or CD), it's highly
unlikely it will match.  1a will give a false, since the first string
does not contain the string 1a anywhere.  Are you looking for a
function that will always return true if any character is a alpha
character ?

See http://www.w3.org/TR/xquery-operators/ for a description of XPath
2 functions and http://www.w3.org/TR/xpath for the description of
XPath 1 functions.

Jon Gorman

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