How to extract JSON value and apply looping and map to corresponding target xml element

44 Views Asked by At

I am facing some issue while extracting XML value from the JSON element using XSLT in OIC, the requirement is to map those XML value to the XML element at target side by applying loop as xml value element is repeating. below are the input and output format, require your expert input-

input

    {
   "requestMessage":{
      "contactName":"",
      "primaryPhoneExt":"",
      "secondaryPhoneExt":"",
      "thirtyMinCallReqFlg":"<cmPCReadingDetails><readingDetailsList><readSequence>1</readSequence><readingUOM>1</readingUOM><readingTOU>1</readingTOU><readingSQI>1</readingSQI><meterRegisterTypeCode>KW</meterRegisterTypeCode><numberOfDials>6</numberOfDials><numberOfDecimals>3</numberOfDecimals><upperLimit>0</upperLimit><lowerLimit>41</lowerLimit><reading>41</reading><newReading>40</newReading><override>false</override><measurementCondition>501000</measurementCondition><measurementDescription>Regular</measurementDescription></readingDetailsList><readingDetailsList><readSequence>2</readSequence><readingUOM>1</readingUOM><readingTOU>1</readingTOU><readingSQI>1</readingSQI><meterRegisterTypeCode>KWH</meterRegisterTypeCode><numberOfDials>5</numberOfDials><numberOfDecimals>0</numberOfDecimals><upperLimit>0</upperLimit><lowerLimit>312</lowerLimit><reading>312</reading><newReading>111</newReading><override>false</override><measurementCondition>501000</measurementCondition><measurementDescription>Regular</measurementDescription></readingDetailsList></cmPCReadingDetails> ",
      "contactPersonPhone":""
   }
}

Target Element-:

    <?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.example.org"
            targetNamespace="http://www.example.org" elementFormDefault="qualified">
    <xsd:element name="thirtyMinCallReqFlg">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="cmPCReadingDetails">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="readingDetailsList" maxOccurs="unbounded">
                                <xsd:complexType>
                                    <xsd:sequence>
                                        <xsd:element name="readSequence" type="xsd:integer"/>
                                        <xsd:element name="readingUOM" type="xsd:integer"/>
                                        <xsd:element name="readingTOU" type="xsd:integer"/>
                                        <xsd:element name="readingSQI" type="xsd:integer"/>
                                        <xsd:element name="meterRegisterTypeCode" type="xsd:string"/>
                                        <xsd:element name="numberOfDials" type="xsd:integer"/>
                                        <xsd:element name="numberOfDecimals" type="xsd:integer"/>
                                        <xsd:element name="upperLimit" type="xsd:integer"/>
                                        <xsd:element name="lowerLimit" type="xsd:integer"/>
                                        <xsd:element name="reading" type="xsd:integer"/>
                                        <xsd:element name="newReading" type="xsd:integer"/>
                                        <xsd:element name="override" type="xsd:string"/>
                                        <xsd:element name="measurementCondition" type="xsd:integer"/>
                                        <xsd:element name="measurementDescription" type="xsd:string"/>
                                    </xsd:sequence>
                                </xsd:complexType>
                            </xsd:element>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>
0

There are 0 best solutions below