uppercase in XSLT/XSL-FO

Jurrie

Usenet Archive
Joined
Sep 30, 2003
Messages
10
Reaction score
0
Hi all,

Is there a function or something in XSLT or XSL-FO to make data from an XML-file uppercase? I ask this becouse I have a XML-document with <title>whatever</title> tags, and i want the data to appear in uppercase in the final PDF-document.

Thanks for any help
 

Alexander Schatten

Usenet Archive
Joined
Jan 17, 2000
Messages
61
Reaction score
0
Hi all,

Is there a function or something in XSLT or XSL-FO to make data from an XML-file uppercase? I ask this becouse I have a XML-document with <title>whatever</title> tags, and i want the data to appear in uppercase in the final PDF-document.

this is not an XSLT, but an XPath issue. there are several xpath string functions, that can easily be found in the XPath standard

http://www.w3.org/TR/xpath#section-String-Functions

look for the translate function. this will solve your problem.

alex
 

Ron Peterson

Usenet Archive
Joined
May 19, 2002
Messages
7
Reaction score
0
Jurrie said:
Is there a function or something in XSLT or XSL-FO to make data from an XML-file uppercase? I ask this becouse I have a XML-document with <title>whatever</title> tags, and i want the data to appear in uppercase in the final PDF-document.

There are some fonts that display upper case characters for both upper and lower case characters.
 

Ben Edgington

Usenet Archive
Joined
Mar 18, 2004
Messages
45
Reaction score
0
Ron Peterson said:
There are some fonts that display upper case characters for both upper and lower case characters.

Alternatively use the translate function from XPath.

With this XML,

- - -
<doc>
<title>Hello, world!</title>
</doc>
- - -

this transformation,

- - -
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:eek:utput omit-xml-declaration="yes"/>

<xsl:template match="/doc">
<xsl:value-of select="translate(title,
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
</xsl:template>

</xsl:stylesheet>
- - -

gives the result

- - -
HELLO, WORLD!
- - -

A neater way to do it if you have more than one occasion to upcase things is to define entities as follows:

- - -
<!DOCTYPE xsl:stylesheet [
<!ENTITY lower "abcdefghijklmnopqrstuvwxyz">
<!ENTITY upper "ABCDEFGHIJKLMNOPQRSTUVWXYZ">
]>

<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:eek:utput omit-xml-declaration="yes"/>

<xsl:template match="/doc">
<xsl:value-of select="translate(title,&lower;,&upper;)"/> </xsl:template>

</xsl:stylesheet>
- - -

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,802
Members
249,594
Latest member
henrywalsh

Latest Threads

Top