Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 105
  • Last Modified:

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

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
sri1209
Asked:
sri1209
1 Solution
 
Geert BormansCommented:
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
 
sri1209Author Commented:
Thanks Geert, i realized i was testing the wrong way, thanks for your help. as always it works.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now