Recent Saxon releases contain a command line argument "-json:myfile.json" to input a JSON file.
But how do I implement the XSLT to parse this JSON? I did not find any doc which handles this directly (without making use of "json-to-xml" or similar).
I only found this: how to convert json to xml with saxonjs?
But this does not help me, because my json starts with an array:
[
{
"eid": "2122.5",
"ecat": "show",
"day": "1629410400",
"spcat": "Bühne",
"time": "19:30",
"text": "Welle",
"remarks": "",
"location": ""
},
{
"eid": "2122.6",
"ecat": "show",
"day": "1629496800",
"spcat": "Bühne",
"time": "19:30",
"text": "Welle",
"remarks": "",
"location": ""
}
]
By writing an intermediate XSLT using the function "json-to-xml", I can convert this JSON to xml that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<array xmlns="http://www.w3.org/2005/xpath-functions">
<map>
<string key="eid">2122.5</string>
<string key="ecat">show</string>
<string key="day">1629410400</string>
<string key="spcat">Bühne</string>
<string key="time">19:30</string>
<string key="text">Welle</string>
<string key="remarks"/>
<string key="location"/>
</map>
<map>
<string key="eid">2122.6</string>
<string key="ecat">show</string>
<string key="day">1629496800</string>
<string key="spcat">Bühne</string>
<string key="time">19:30</string>
<string key="text">Welle</string>
<string key="remarks"/>
<string key="location"/>
</map>
</array>
How can I create a template that matches the root item, and how can I call "apply-templates" to trigger another template that handles the items?