14 - The translate() function

XSLT script: iliad14.xsl
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="/">
	<xsl:for-each select="document/poem/line">
	<p>
	<xsl:value-of select="xsl:value-of select="translate(., 'aeiou', 'AEIOU')"" /> <br/>
	</p>
	</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

This stylesheet uses multiple instances of the translate() function to convert each lower-case vowel to upper-case.

Syntax:   translate('string1', 'string2', 'string3')

Returns string1 with all occurrences of the characters in string2 replaced by the matching characters in string3.


RESULTS of iliad14.xsl

SIng, Oh gOddEss, AbOUt thE wrAth Of AchIllEs sOn Of PElEUs,
thE AccUrsEd wrAth whIch cAst A myrIAd Of pAIn UpOn thE AchAEAns
And sEnt fOrth mAny nOblE sOUls Of hErOEs tO HAdEs,
mAkIng thEm prEy fOr dOgs And All bIrds.
ThE wIll Of ZEUs wAs fUlfIllEd,
whEn, In fAct, thE twO mEn fIrst pArtEd wAys In strIfE,
thE sOn Of AtrEUs, rUlEr Of mEn, And gOd-lIkE AchIllEs.