Using XSLT to convert adhoc element name to attribute name

Moonbeam66

Usenet Archive
Joined
Jun 7, 2005
Messages
2
Reaction score
0
I'm looking to convert an element name to an attribute name, where the element name is user-defined. For example <accountNumber>12345678</accountNumber>. I want to convert this to <userTag name="accountNumber">12345678</userTag>. Where I'm having probs is getting the element name to appear as the value for the attribute in the transformed XML. Any ideas?

If I use the following XSL

<xsl:attribute name="name">
name
</xsl:attribute>

I get the following result:

<userTag name="name"> .. </userTag>

I get the same sort of result if I just use "." instead of "name".

Thanks
 

Richard Tobin

Usenet Archive
Joined
Jan 6, 2000
Messages
4,251
Reaction score
0
<xsl:attribute name="name">
name
</xsl:attribute>

<xsl:attribute name="name">
<xsl:value-of select="name"/>
</xsl:attribute>

or if you are using a literal result element use an attribute value template:

<userTag name="{name}">

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,246
Members
248,133
Latest member
DujonT

Latest Threads

Top