I wrote a request xsl that transforms an xml request to another one but it doesn't work as expected



The Request in xml is :



<NS2:BookTicket xmlns:NS2="http://ift.tt/1w8OOy4">
<NS2:transaction_header>
<NS3:Ticket_id xmlns:NS3="http://ift.tt/1uV1mym">
1993</NS3:Ticket_id>
<NS4:request_datetime xmlns:NS4="http://ift.tt/1uV1mym">
2014-11-04T15:26:27</NS4:request_datetime>
<NS5:request_reference_no xmlns:NS5="http://ift.tt/1uV1kXe">
141104165416</NS5:request_reference_no>
<NS6:send_sms xmlns:NS6="http://ift.tt/1uV1kXe">
N</NS6:send_sms>
<NS7:send_sms_language xmlns:NS7="http://ift.tt/1uV1kXe">
en</NS7:send_sms_language>
</NS2:transaction_header>
<NS2:transaction_body>
<NS2:idn>00201220202121</NS2:idn>
<sss>2570778508</sss>
</NS2:transaction_body>
</NS2:BookTicket>


The output xml that is expected (That I want) is :



<Root>
<numberid1>00201220202121</numberid1>
<numberid2>2570778508</numberid2>
</Root>


(I want to extract the value inside idn and put it in a new element in the transformed xml request called also I want to extract the value insides sss and put it in a new element in the transformed xml request called )


I wrote this request xslt:



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://ift.tt/tCZ8VR"
version="1.0"
xmlns:xalan="http://ift.tt/w7zGWI">
<xsl:template match="/">
<xsl:element name="Root">
<xsl:choose>
<xsl:when test="*//BookTicket">
<xsl:element name="numberid1">
<xsl:value-of select="*//idn" />
</xsl:element>
<xsl:element name="numberid2">
<xsl:value-of select="*//sss" />
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:element>
</xsl:template>
</xsl:stylesheet>


The Actual transformed xml after applying xsl is : Why can't it find the BookTicket or create the new elements? is it something related to namespaces?


No comments:

Post a Comment