How to translate to uppercase some text
Posted: Wed Aug 21, 2013 5:58 pm
Hi, I'm an Oxygen user for about a year.
I never posted on this forum before because I've always found all the answers I needed and I am very grateful for this.
Now I was trying to translate some part of text from lowercase to uppercase.
It's embarrassing
but I can't figure out how to select just the string I need to translate.
Here an example of the file I'm working on:
I need to translate to uppercase the text tagged as "small", like this:
And this is the XSLT I was trying to apply:
This is obviously transforming all the text in uppercase.
How can I make it work only for the text tagged as "small"?
I spent some days trying to understand better XSLT and XPath
but I just can't figure it out.
Thanks a lot!
I never posted on this forum before because I've always found all the answers I needed and I am very grateful for this.

Now I was trying to translate some part of text from lowercase to uppercase.
It's embarrassing

Here an example of the file I'm working on:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Lorem ipsum</title>
</head>
<body>
<p>Lorem <small>ipsum</small> dolor sit amet, consectetur adipiscing elit. Integer ullamcorper.</p>
<p>Lorem ipsum dolor sit <small>amet</small>, consectetur adipiscing elit. Integer ullamcorper.</p>
</body>
</html>
Code: Select all
<p>Lorem <small>IPSUM</small> dolor sit amet, consectetur adipiscing elit. Integer ullamcorper.</p>
<p>Lorem ipsum dolor sit <small>AMET</small>, consectetur adipiscing elit. Integer ullamcorper.</p>
And this is the XSLT I was trying to apply:
Code: Select all
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="smallCase" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upperCase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="translate(., $smallCase, $upperCase)"/>
</xsl:template>
</xsl:stylesheet>
How can I make it work only for the text tagged as "small"?
I spent some days trying to understand better XSLT and XPath

Thanks a lot!