Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Transformation of text with nested elements >Thread Next - Re: Transformation of text with nested elements Re: Transformation of text with nested elementsTo: NULL Date: 5/11/2005 7:15:00 AM
"Mathias Harbeck" <harbeck@g...> wrote in message
news:1h5wmfbcwnbxv.16emk3pydluj7.dlg@4......
> Hi,
>
> i have a xml passage that looks like this:
>
> <title>this is a <super>title</super> with superscript <sub>and</sub>
> subscript.</title>
>
> The transformation should do the following things:
> - preservere the structure
> - change *all* text to uppercase
>
> The result should be the following:
>
> <title>THIS IS A <super>TITLE</super> WITH SUPERSCRIPT <sub>AND</sub>
> SUBSCRIPT.</title>
>
> I searched the whole day for a working solution but couldn't find
> anything.
> This is what i am able to do up to now:
> - uppercase the whole string but loose the nested elements ("THIS IS A
> TITLE WITH SUPERSCRIPT AND SUBSCRIPT"; simply by matching "title" and
> using
> "translate()" on ".")
> - preserver the structure and uppercase the nested elements ("This is a
> <super>TITLE</super> with superscript <sub>AND</sub> subscript.</title>";
> matching "title", calling "apply-templates", matching "sub" and "super",
> inserting sub/super-elements and using "translate()" on ".").
>
> Has anyone an idea how a could realize this?
>
> TIA
> Mathias
Just override the identity rule like this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="lower" select=
"'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" 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(.,$lower,$upper)"/>
</xsl:template>
</xsl:stylesheet>
There is no upper-case() function in XPath 1.0 -- it is part of XPath 2.0
Functions and Operators, which is still a draft.
Cheers,
Dimitre Novatchev.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
