Subject: Re: [xsl] copy and translate an element and its children From: "J.Pietschmann" <j3322ptm@xxxxxxxx> Date: Thu, 03 Jul 2003 21:02:19 +0200 |
Hello, I am currently using <xsl:variable name="short-title"> <xsl:for-each select="title/node()"> <xsl:if test="not(position()=1)"> <xsl:copy-of select="."/> </xsl:if> </xsl:for-each> </xsl:variable> This copies all nodes unchanged.
Isn't it better to use <xsl:variable name="short-title" select="title/node()[position() > 1]"/> Avoids copying.
However, what I'd now like to be able to do is create the same variable but with the contents of each node copied translated to uppercase. Is there an elegant way to do this?
thanks,
Well, try <xsl:variable name="short-title"> <xsl:apply-templates select="title/node()[position() > 1]" mode="upcase"/> </xsl:variable> ... <xsl:template match="*|@*" mode="upcase"> <xsl:copy> <xsl:apply-templates select="*|@*" mode="upcase"/> <xsl:copy> </xsl:template>
<xsl:template match="text()" mode="upcase"> <xsl:value-of select="translate(.,'abcde...','ABCDE...')"/> </xsl:template> Beware, untested.
Complete the mapping in the translate() to your needs (you might want to upcase non-ASCII too).
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] copy and translate an element, Matthew L. Avizinis | Thread | Re: [xsl] copy and translate an ele, David Carlisle |
Re: [xsl] Transforming the XSL-List, J.Pietschmann | Date | Re: [xsl] copy and translate an ele, David Carlisle |
Month |