- Jun 2, 2009
Changing the Case of a String
When manipulating text, it’s often important to be able to change letters from upper- to lowercase and back again.
To capitalize strings:
- Type translate(.
- Then, type the expression which contains the source string.
- Next, type , 'abcdefghijklmnopqrstuvwxyz' (that is; a comma, a space, and the string which contains the letters to change).
- Then, type , 'ABCDEFGHIJKLMNOPQRST UVWXYZ' (that is; a comma, a space, and the string which contains the letters that you want to replace from Step 3).
- Finally, type ) to complete the function (Figure 4.18).
Figure 4.18 After the XSLT in Figure 4.16, each wonder’s city and country is displayed in a separate column in the Overview section.
x s l t ... <p align="center"> <strong><xsl:value-of select=" translate(../name[@language='English'] ,'abcdefghijklmnopqrstuvwxyz' ,'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> </strong><br /> <xsl:apply-templates select=" ../main_image"/> </p> ...
Figure 4.19. In the History section, I am going to output the wonder’s name above the image of the wonder. And I am going to translate the wonder’s name to be all uppercase.