0

can any one help to solve this, i am trying to convert my xml to json using xslt3.0 function(xml-to-json) its not accepting my xml format, now I am trying to convert my XML to another format of XML which contains tag name as attribute and value as value and tag name as data type using xslt 3.0 .

input xml:

<widget>
    <debug>on</debug>
    <window title="Sample Konfabulator Widget">
        <name>main_window</name>
        <width>500</width>
        <height>500</height>
    </window>
    <image src="Images/Sun.png" name="sun1">
        <hOffset>250</hOffset>
        <vOffset>250</vOffset>
        <alignment>center</alignment>
    </image>
    <text data="Click Here" size="36" style="bold">
        <name>text1</name>
        <hOffset>250</hOffset>
        <vOffset>100</vOffset>
        <alignment>center</alignment>
        <onMouseUp>
    sun1.opacity = (sun1.opacity / 100) * 90;
        </onMouseUp>
    </text>
</widget>

output xml:

<?xml version="1.0" encoding="UTF-8"?>
<map xmlns="http://www.w3.org/2005/xpath-functions">
    <map key="Order">
        <map key="InvestmentAccount">
            <string key="AccountNumber">10</string>
        </map>
        <map key="Parcel">
            <string key="Limit">0</string>
            <string key="ExpiryDate">1900-01-01T00:00:00</string>
            <array key="Asset">
                <map>
                    <string key="Open">25.15</string>
                    <string key="High">25.15</string>
                    <string key="Low">25.11</string>
                    <string key="Close">25.87</string>
                </map>
                <map>
                    <string key="Open">25.15</string>
                    <string key="High">25.15</string>
                    <string key="Low">25.11</string>
                    <string key="Close">25.87</string>
                </map>
            </array>
        </map>
        <string key="OrderDate">2012-10-11T21:46:03.6489906+11:00</string>
    </map>
</map>
Ed Bangga
  • 12,879
  • 4
  • 16
  • 30
  • The input XML is exactly the same as in https://stackoverflow.com/questions/45739445/xml-to-json-transformation-in-xslt-3-0, the output you have shown does not seem to have any relation to the input. If your task is to transform the input you have shown to the format `xml-to-json` expects then use the approach given in the answer in the referenced question. If you really want to transform the posted input to the posted output then you will need to explain the relation, I don't see any dateTimes for instance in the input, so I have no idea where the dateTimes in the output come from. – Martin Honnen Aug 18 '17 at 12:48
  • Thank you, but while doing with that snippet i am unable to parse the xslt . i am getting the following exception, SXXP0003: Error reported by XML parser: The prefix "fn" for element "fn:map" is not bound. can you please help me on this. – purushotham nadipali Aug 18 '17 at 13:02
  • 1
    Well, bind `xmlns:fn="http://www.w3.org/2005/xpath-functions"` of course as the whole task is to transform your custom XML to the format defined in https://www.w3.org/TR/xpath-functions-31/#func-xml-to-json. – Martin Honnen Aug 18 '17 at 13:07

0 Answers0