XSLT / XPath: no uppercase function in MSXML 4.0?

I am trying to use upper-case () in XPATH, my parser is MSXML 4.0 and I get:

upper-case is not a valid XSLT or XPath function. 

Is this really not implemented?

+4
xpath xslt uppercase
Aug 04 '09 at 8:16
source share
2 answers

In xslt 1.0, there are no functions to convert to uppercase or lowercase. Instead, do the following:

If required in many places:

Declare these two xsl variables (this should make xslt more readable)

 <!-- xsl variables up and lo and translate() are used to change case --> <xsl:variable name="up" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> <xsl:variable name="lo" select="'abcdefghijklmnopqrstuvwxyz'"/> 

And use them in your translation function to change the case

 <xsl:value-of select="translate(@name,$lo,$up)"/> 

If you need to use it in only one place, you do not need to declare variables

 <xsl:value-of select="translate(@name,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> 
+13
Aug 04 '09 at 8:27
source share
— -

Perhaps this may help you:

 translate(string, string, string) 

The translation function takes a string and, by character, translates the characters that correspond to the second string into the corresponding characters of the third string. This is the only way to convert from lowercase to uppercase in XPath. It will look like this (with the addition of an extra space for readability). This code will capitalize the names of employees, and then select those employees whose names begin with A.

 descendant::employee[ starts-with( translate(@last-name, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"), "A" ) ] 

If the second line has more characters than the third line, these extra characters will be removed from the first line. If the third line has more characters than the second line, additional characters are ignored.

(from http://tutorials.beginners.co.uk/professional-visual-basic-6-xml-part-1-using-xml-queries-and-transformations.htm?p=3 )

+2
Aug 04 '09 at 8:25
source share



All Articles