Welcome to WebmasterWorld Guest from

Forum Moderators: httpwebwitch

Message Too Old, No Replies

Using XSLT to Change Root Tag Name According to the Feeding XML

6:00 pm on Oct 6, 2008 (gmt 0)

New User

5+ Year Member

joined:Oct 6, 2008
posts: 1
votes: 0

I am a new XSLT developper. I have this request to fulfill, please help.

Example XML feed:
<emea_created_ticket customer='abc'>

According to the value of xml_transaction_type, the root node after transfomation need to be different, eg.
if xml_transaction_type='order', the transformed xml will be like:

<nt_created_order customer='abc'>

If xml_transaction_type='ticket' or anything else, the transformed xml will be like:
<nt_created_ticket customer='abc'>

I am able to change the tag names and content in ... area, but can't change the root tag name. If you have answer, please let me know.



7:31 pm on Oct 6, 2008 (gmt 0)

Moderator This Forum from CA 

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
votes: 0

XSLT has "if" and "choose" functionality. You'll need to construct an XPATH expression to find and evaluate the "<xml_transaction_type>" node, and depending on its value, create a "<nt_created_ticket>" or a "<nt_created_order>" node.

suggested resources:

XSLT Choose element [w3schools.com]

XPATH axes [w3schools.com]