Solved

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

Posted on 2015-02-16
2
75 Views
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:text>MA</xsl:text>
<xsl:if test="Approval/HA ='D' or Approval/HA= 'T' or  Approval/HA= 'C'">
  <xsl:text>P</xsl:text>
</xsl:if>
</xsl:variable>
 <xsl:element name="{$ename}"> <xsl:copy-of select="@*"/>
 <xsl:apply-templates select="node()"/>
 </xsl:element>
 </xsl:template>
0
Comment
Question by:sri1209
2 Comments
 
LVL 60

Accepted Solution

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

<Details>
    <MA>
        <Approval>
            <HA>C</HA>
        </Approval>
    </MA>
</Details>

Open in new window


With this XML your code simply works

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

Author Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now