xsl-list
[Top] [All Lists]

Re: Changing tag text

2004-10-27 12:16:46
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(_at_)gmail(_dot_)com> 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

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--




<Prev in Thread] Current Thread [Next in Thread>