473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using XSLT to convert adhoc element name to attribute name

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

Jul 20 '05 #1
2 1424
In article <11*********************@g49g2000cwa.googlegroups. com>,
Moonbeam66 <km********@gmail.com> wrote:
<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
Jul 20 '05 #2
Richard,

That worked a treat.

Thanks very much.

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Mark Constant | last post by:
I have a drop-down list now and I got it so when something is selected from the drop down list it calls a JavaScript function. I want it so the value selected from the drop-down list is sent as a...
2
by: nanookfan | last post by:
Hi all, I'm having a bizarre problem converting XML files to HTML using an XSLT. The problem is only occuring in my Netscape 7.0 browser. What makes it more bizarre is that it is only...
3
by: Sandros | last post by:
Background: I'm collecting usability statistics for a group of applications. Each count has the following attributes: date, application, major heading, minor heading, count. My intent is to pull...
3
by: David Elliott | last post by:
I wrote an application to scrape a database and create an XSD file which will be annotated by a map file in order to create a Typed DataSet. I was wondering if I could do the annotation using...
1
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
1
by: adi | last post by:
hello all, seems like a simple issue, but having tried several approaches with no success I am posting this question, I have a XML in one format, I want to now convert into another XML format...
4
by: simon.a.hulbert | last post by:
Hi, I'm trying to view the following xslt transformation using firefox <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" > <xsl:output method = "xml" indent =...
3
by: C.W.Holeman II | last post by:
I am new to using XML. I am using Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1. In my test I am attempting to have the style sheet:...
1
by: Pathik | last post by:
Hi All, Currently I am trying to convert one xml file into another xml file which having different format than original xml file. my input xml file is like: <?xml version="1.0"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.