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 elementsTo: NULL Date: 5/10/2005 7:28:00 PM Mathias Harbeck wrote:
> 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
To preserve text node and element sequence and tags use <xsl:copy-of
select="" />
A reference on copy-of is here: http://www.w3schools.com/xsl/el_copy-of.asp.
To upper case the text, you may have to parse through the nodes with
generic templates:
<xsl:template match="node()">
<xsl:variable name="EltName" select="name()" />
<xsl:element name="{$EltName}">
<xsl:value-of select="upper-case(.)" />
</xsl:element>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="upper-case(.)"/>
</xsl:template>
The select from the parent would be something like this
<xsl:apply-templates select="node()" />
HTH
Regards,
N. Demos
--
Change "seven" to a digit to email me.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
