By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,714 Members | 1,345 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,714 IT Pros & Developers. It's quick & easy.

XSL. howto create an element of a text node?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.