homepage Welcome to WebmasterWorld Guest from 54.237.213.31
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

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

5+ Year Member



 
Msg#: 3759864 posted 6:00 pm on Oct 6, 2008 (gmt 0)

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

Example XML feed:
<emea_created_ticket customer='abc'>
<ticket_id>TT00887872</ticket_id>
...
<xml_transaction_type>ticket</xml_transaction_type>
</emea_created_ticket>

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'>
...
</nt_created_order>

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

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.

Thanks,

Wenlan

 

httpwebwitch

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



 
Msg#: 3759864 posted 7:31 pm on Oct 6, 2008 (gmt 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]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved