perform XSL Transformation to get a normal XML response, then JSON ?

The below response is dynamic. Extra details get added to the response. I want to perform XSL Transformation to get a normal XML response . I would then convert it to get the below response in JSON format

Actual Response

<feed 
    xmlns="http://www.w3.org/2005/Atom" 
    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
    xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"xml:base="https://abcd.xyz.com/sap/opu/odata/sap/ZHR_TIMESHEET_APPROVE_SER_GW_SRV/">
  ");">
  <id>...</id>
  <title type="text">FtTimesheetDetSet</title> 
  <updated>2016-04-19T11:46:21Z</updated>
  ");">
  <author>...</author>
  <link href="FtTimesheetDetSet" rel="self" title="FtTimesheetDetSet"/>
  ");">
  <entry>
    ");">
    <id> https://abcd.xyz.com/sap/opu/odata/sap/ZHR_TIMESHEET_APPROVE_SER_GW_SRV/FtTimesheetDetSet('1234') </id>
    <title type="text">FtTimesheetDetSet('1234')</title> 
    <updated>2016-04-19T11:46:21Z</updated> 
    <category term="ZHR_TIMESHEET_APPROVE_SER_GW_SRV.FtTimesheetDet" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/> 
    <link href="FtTimesheetDetSet('1234')" rel="self" title="FtTimesheetDet"/>
    ");">
    <content type="application/xml">
      ");">
      <m:properties 
          xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
          xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
        <d:Pernr>1234</d:Pernr> 
        <d:Ename>Test Name</d:Ename> 
        <d:Begda>2016-04-11T00:00:00</d:Begda> 
        <d:Endda>2016-04-17T00:00:00</d:Endda> 
        <d:NotCompleted/> 
        <d:Completed/> 
        <d:Submitted>X</d:Submitted> 
        <d:Approved/> 
        <d:Rejected/> 
        <d:Transferred/> 
        <d:CancelTransfer/> 
        <d:ReqReject/> 
        <d:Recall/> 
        <d:ReqUnlock/> 
        <d:ApprovedReject/> 
        <d:ApprovedUnlock/> 
        <d:ActualHours>80.00</d:ActualHours> 
        <d:TargetHours>40.00</d:TargetHours> 
        <d:AccessHours>0.00</d:AccessHours> 
        <d:BillableHours>80.00</d:BillableHours> 
        <d:NonbillableHours>0.00</d:NonbillableHours> 
        <d:LeaveHours>0.00</d:LeaveHours> 
        <d:HolidayHours>0.0</d:HolidayHours> 
        <d:Lastmodifiedby>A123</d:Lastmodifiedby> 
        <d:Remarks>Submitted</d:Remarks> 
        <d:Exempted/> 
        <d:Supvr>45678</d:Supvr> 
        <d:ReasonForTsUnlck/> 
        <d:Ccg2No/> 
        <d:Ccg2Name/> 
        <d:Ccg1No/> 
        <d:Ccg1Name/> 
        <d:Ccg1LdEid/> 
        <d:Ccg1LdName/> 
      </m:properties>
    </content>


  </entry>


</feed>

Required Response:

[ timesheet:{ employeeId:string name:string actualHours:integer targetHours:integer billableHours:integer nonBillableHours:integer leaveHours:integer holidayHours:integer currentState:string remarks:string } ]
0 4 523
4 REPLIES 4

Not applicable

Hello @akash ojha,

There is a Apigee Built in Policy available at "http://docs.apigee.com/api-services/reference/xsl-transform-policy". Does it help you ?

Trying to convert from jsontoXML to xslt but we are facing error. Is there any possibility to work with normal xml file to xslt?

Hi - please Ask a New Question by clicking the "Ask a Question" button. This works better than appending your question as a comment to a 1+ year-old thread.

5553-ask-a-question.png

Also, when you ask your new question, you will need to provide more details around:

  • what you are doing or trying - including specific code and configuration
  • what you are seeing, specifically. "We are facing error" is not specific enough.
  • What you are expecting to see, specifically.

You need to be specific in order for us to have a hope of helping you.

Unfortunately, "I am trying JSONToXML and facing error" is not a question we can help you with. So please do take the time to explain specifically what you are seeing and what you expect to see.

Hi, I know this question is an old one. But the Required Response is not JSON. Can you explain further?

It's possible to get the output with XSLT, though. XSLT need not generate XML.