Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development

  • Print
  • + Share This
  • 💬 Discuss
This chapter is from the book

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:

  1. Type translate(.
  2. Then, type the expression which contains the source string.
  3. Next, type , 'abcdefghijklmnopqrstuvwxyz' (that is; a comma, a space, and the string which contains the letters to change).
  4. 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).
  5. Finally, type ) to complete the function (Figure 4.18).
    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.

  • + Share This
  • 🔖 Save To Your Account

Discussions

comments powered by Disqus