Running xpaths against a xml doc (comming from a mssql server) and having trouble with case sensitive letters.
I have tried to use the xml translate funktion, but it would need an exact match in the DB anyway. If I look for the name John and it is typed JohN in the DB I get nothing. Is the only solution to 'wash' the data in the DB.
Are there any work around to make a xpath query non case sensitive

XPath and case sensitive problems
admoloc
jimmyshu
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnxml/html/practexslt.asp
You can use the str2:uppercase function to make your comparisons case-insensitive.
donald_hodges
< xml version="1.0" encoding="UTF-8" >
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts">
<msxsl:script language="JScript" implements-prefix="user">
<![CDATA[
function uppercase(r)
{
r.toUpperCase();
}
]]>
</msxsl:script>
<xsl:template match="*">
<xsl:value-of select="user:uppercase(string(.))"/>
</xsl:template>
</xsl:stylesheet>
This code transforms all text generic to upper case but drops out alle the elements, so there is no tags left in the browser view. Any idea on how to keep xml element and just translate their text to uppercase.
vgrigor
looking like this:
xpath = @"//Person[" + "translate("+sCol+",'abcdefghijklmnopqrstuvwxyzaoa','ABCDEFGHIJKLMNOPQRSTUVWXYZAOA')" + "='"+sValue.ToUpper()+"']";
where sCol is the element and sValue is the search value.
Thx,
Jakob
BANND
expr = nav.Compile(
String.Format("//{0}[str2:uppercase(.)='{1}']", elementName, searchText.ToUpper()));Alex61291
xpath: //Person[starts-with(Name, 'John')]
or
xpath: //Person[starts-with(Name, translate('John', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'))]
I might have a entery where the user wrote JohN in the database. JohN will not be found.
Has I see it str2:uppercase or the translate function will not make a xpath search case-insensitive.
klaus klaussen
//Person[starts-with(Name, 'John')]
I cannot see how I can access the XML doc element text, to force it to upper case.
Thx,
Jim
Atomican
//Person[starts-with(str2:uppercase(Name), 'JOHN')]
The only part I'm not certain about is Name, it appears that is a sub-element of Person in your XML and I'm not sure of the correct syntax to specify that in the XPATH query as I usually have to play around and tweak some when creating XPATH queries. The period in my query represent the text of the current element, which wouldn't apply for you. If name were an attribute it would be "@Name" here, but if it is a subelement you may have to specify "child::Name" in its place.