0

I am a newbie to XSLT . I have been trying to transform my XML to required format using XSLT but it is not working - Below is the XSLt im trying with Please help

My input XML:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 

xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Body>
      <insertResponse xmlns="http://www.mytst.com/u_tst_event_staging">
         <sys_id>12349c811bd25vwxyzf3964c0a4b1234</sys_id>
         <table>em_event</table>
         <display_name>sys_id</display_name>
         <display_value>Created 2020-07-27 13:17:15</display_value>
         <status>inserted</status>
         <error_message>Unable to format ? using format string yyyy-MM-dd HH:mm:ss for field processed</error_message>
      </insertResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

My Required format

<?xml version="1.0" encoding="UTF-8"?>
<CreateTicketResponse xmlns="http://xmlns.oracle.com/sysman/connector" xmlns="http://www.mytst.com/u_tst_event_staging">
   <TicketId>12349c811bd25vwxyzf3964c0a4b1234</TicketId>
   <InstanceVariable>
      <VariableName>sys_id</VariableName>
      <VariableValue>12349c811bd25vwxyzf3964c0a4b1234</VariableValue>
   </InstanceVariable>
</CreateTicketResponse>

My XSLT

  <?xml version="1.0" encoding="UTF-8"?>
    <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns="http://www.mytst.com/u_tst_event_staging"
                  xmlns="http://xmlns.oracle.com/sysman/connector">
     <xsl:template match=CreateTicketResponse">
       <CreateTicketResponse>
         <TicketId>
           <xsl:value-of select="sys_id"/>
         </TicketId>
         <InstanceVariable>
           <VariableName>sys_id</VariableName>
           <VariableValue>
             <xsl:value-of select="sys_id"/>
           </VariableValue>
         </InstanceVariable>
       </CreateTicketResponse>
     </xsl:template>
    </xsl:transform
Chilarai
  • 1,842
  • 2
  • 15
  • 33
Laks
  • 1
  • 1
  • See: https://stackoverflow.com/questions/34758492/xslt-transform-doesnt-work-until-i-remove-root-node/34762628#34762628 – michael.hor257k Jul 27 '20 at 10:47
  • You've fallen into the common trap of ignoring namespaces. Search for "XSLT default namespace" to find many others who have done the same. – Michael Kay Jul 27 '20 at 11:35

0 Answers0