470,848 Members | 1,653 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

XSL. howto create an element of a text node?

Hello,

I have a XML file

<car>
<brand>Mercedes</brand>
</car>

I want to transform it to this form:

<car>
<Mercedes>
</car>

So in fact in XSL I want to create an element which has the name of a
text node. This might be a really simple question but I am getting
confused with XPath now, with {}, with // with self:: with parent::
..... :-(

<xsl:template match="car">
<xsl:element name="XXXX"/>
</xsl:template>

How would be the valid XXXX expression?

Thanks for help

Bernd

Apr 3 '06 #1
1 1471
bl*******@gmx.net wrote:
I want to transform it to this form:

<car>
<Mercedes>
</car>


I think you mean this (note the closure of the empty tag)
<car>
<Mercedes/>
</car>
<xsl:template match="car">
<xsl:element name="{./brand}"/>
</xsl:template>

I wouldn't do this though. Dynamically creating new element names is a
whole can of worms and you really don't want to go there.

Apr 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Rolf Kemper | last post: by
6 posts views Thread by Ron Brennan | last post: by
1 post views Thread by jason.lucey | last post: by
2 posts views Thread by pintihar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.