replace tag of the xml by reading on of the tag value

Posted on 2015-02-16
Last Modified: 2015-02-20
Hi ,

i am trying to change one of the xml tags <MA> to <MAP> by reading the value of some other tag in the same parent node, here i am reading "Approval/HA " value and change the tag , but its only working if  Approval/HA ='D' is true , its not working for other conditions. can somebody let me know if the "or" condition should be the way as below or is different.

Thanks for the help.

<xsl:template match="Details/MA">
 <xsl:variable name="ename">
<xsl:if test="Approval/HA ='D' or Approval/HA= 'T' or  Approval/HA= 'C'">
 <xsl:element name="{$ename}"> <xsl:copy-of select="@*"/>
 <xsl:apply-templates select="node()"/>
Question by:sri1209
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 60

Accepted Solution

Geert Bormans earned 500 total points
ID: 40613752
It always helps if you posted an example XML.
I created one myself


Open in new window

With this XML your code simply works

and yes, that is the way to do "or"

Author Comment

ID: 40620977
Thanks Geert, i realized i was testing the wrong way, thanks for your help. as always it works.

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

736 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question