Re: [xsl] Changing tag text

Subject: Re: [xsl] Changing tag text
From: Gary Hegenbart <ghegenbart@xxxxxxxxx>
Date: Wed, 27 Oct 2004 12:16:46 -0700
Hank,
If you want to use a : in the tag name, be sure to include a namespace
declaration in the output XML.  Or use a different character, which is
what I did in the example below.  It seemed to work in my test,
someone else may have another (better?) way of doing it.

<xsl:template match="/">
 		<xsl:call-template name="chName" />	
</xsl:template>

<xsl:template name="chName">
	<xsl:for-each select="child::node()">
	<xsl:choose>
		<xsl:when test="not(self::*)">
			<xsl:value-of select="." />
		</xsl:when>
		<xsl:when test="self::*">
 			<xsl:variable name="elname" select="concat('xsl_', name())" />
	 		<xsl:element name="{$elname}"> 
				<xsl:call-template name="chName" />
			</xsl:element>
		</xsl:when>
	</xsl:choose>
	</xsl:for-each> 
</xsl:template>

Let me know how it works 
-- 
Gary Hegenbart

On Tue, 26 Oct 2004 15:58:58 -0500, Hank Hepler <hankhepler@xxxxxxxxx> wrote:
> Hello all,
> I need some guidance on how to go about changing a tag name in a
> transform from one XML file to another XML file, or actually appending
> something on the tag name like so:
> <Atag>some data</Atag>
> to
> <xsl:Atag>somedata</xsl:Atag>
> 
> I need it to add the "xsl:" to each tag. Seems like it would be a
> simple answer but just not seeing it right now and any help will be
> greatly appreciated!
> 
> Thanks,
> Hank

Current Thread