Convert JSON to XML within XML Using XSLT 1.0

How can you convert a JSON String Within XML to XML but using XSLT 1.0. The input xml would be like this:

<root>
    <element>
        <code>110</code>
    <Currency>USD</Currency>
    <Datub>{"KLH":"A523","KSCH":"Z004","COMNS":"PCE","ECON":[{"KAB":1,"KBTR":0.00},{"KAB":100,"KBTR":-8.33},{"KAB":300,"KBTR":-15.00}]}</Datub>
    </element>
    <element>
    <code>111</code>
    <Currency>EUR</Currency>
    <Datub>{"KLH":"A","KSCH":"Z0","COMNS":"PCE","KEBIR":-0.00,"KONMA":"%","ECON":[{"KAB":1,"KBTR":0.00},{"KAB":100,"KBTR":-8.33},{"KAB":300,"KBTR":-15.00}]}</Datub>
    </element>
</root>

The output should look like this:

<root>
   <element>
        <code>110</code>
        <Currency>USD</Currency> 
        <Datub>
            <KLH>A</KLH>
            <KSCH>Z004</KSCH>
            <COMNS>PCE</COMNS>
            <KEBIR>-0.00</KEBIR>
            <KONMA>%</KONMA>
            <ECON>
                <element>
                    <KAB>1</KAB>
                    <KBTR>0.0</KBTR>
                </element>
                <element>
                    <KAB>100</KAB>
                    <KBTR>-8.33</KBTR>
                </element>
                <element>
                    <KAB>300</KAB>
                    <KBTR>-15.0</KBTR>
                </element>
            </ECON>
        </Datub>
    </element>
    <element>
        <code>111</code>
        <Currency>EUR</Currency>
        <Datub>
            <KLH>A</KLH>
            <KSCH>Z0</KSCH>
            <COMNS>PCE</COMNS>
            <KEBIR>-0.00</KEBIR>
            <KONMA>%</KONMA>
            <ECON>
                <element>
                    <KAB>1</KAB>
                    <KBTR>0.00</KBTR>
                </element>
                <element>
                    <KAB>100</KAB>
                    <KBTR>-8.33</KBTR>
                </element>
                <element>
                    <KAB>300</KAB>
                    <KBTR>-15.00</KBTR>
                </element>
            </ECON>
        </Datub>
    </element>
</root>

I tried out the solution at How to convert json to xml using xslt. It does have an example with stylesheet 1.0 but it does not not copy the json array fields and parent xml fields.

Read more here: Source link