BaseMax / BaseMax/json-to-xml-converter

Functionality to imitate function json-to-xml of XPath 3.1

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Convert by types and set attribute keys.

I have created this code, based on yours, to create XML files which comply with the function "json-to-xml" of XPath 3.1.

https://git.xmpp-it.net/sch/Focus/commit/5c3fdf9dfd4ee0c8c3ded9138240e88ea470bb82

```
python xpath-functions-31-json-to-xml.py ; cat file.json ; xmllint file.xml --format
```

```json
{
"content": [
{
"id": 70805774,
"value": "1001",
"position": [1004.0,288.0,1050.0,324.0]
}
]
}
```

```xml



70805774
1001

1004.0
288.0
1050.0
324.0


```

There is more to add, such as `escaped="true"`.

> The expression `json-to-xml('{"x": "\\", "y": "\u0025"}', map{'escape': true()})` returns (with whitespace added for legibility):
```

\\
%

```

Reference:

https://w3.org/TR/xpath-functions-31/#func-json-to-xml

Demonstration (XSLT Fiddle):

```
https://martin-honnen.github.io/xslt3fiddle/?xslt=%3C%3Fxml+version%3D%221.0%22%3F%3E%0D%0A%3Cxsl%3Astylesheet%0D%0A%09xmlns%3Axsl%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2FXSL%2FTransform%22%0D%0A%09xmlns%3Amath%3D%22http%3A%2F%2Fwww.w3.org%2F2005%2Fxpath-functions%2Fmath%22%0D%0A%09xmlns%3Axs%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%0D%0A%09exclude-result-prefixes%3D%22xs+math%22+version%3D%223.0%22%3E%0D%0A%09%3Cxsl%3Aoutput+indent%3D%22yes%22+omit-xml-declaration%3D%22yes%22+%2F%3E%0D%0A%0D%0A%09%3Cxsl%3Atemplate+match%3D%22data%22%3E%0D%0A%09++++%3Cxsl%3Acopy-of+select%3D%22json-to-xml%28.%29%22%2F%3E%0D%0A%09%3C%2Fxsl%3Atemplate%3E%0D%0A%3C%2Fxsl%3Astylesheet%3E&input=%3Cdata%3E%7B%0D%0A%09%22content%22%3A+%5B%0D%0A%09++%7B%0D%0A%09++++%22id%22%3A+70805774%2C%0D%0A%09++++%22value%22%3A+%221001%22%2C%0D%0A%09++++%22position%22%3A+%5B1004.0%2C288.0%2C1050.0%2C324.0%5D%0D%0A%09++%7D%0D%0A%09%5D%0D%0A%7D%3C%2Fdata%3E&input-type=XML
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked reference implementation and the XPath 3.1 json-to-xml specification, then inspect the converter's current JSON-to-XML entry point. Compare its output with the provided map, array, numeric, string, key, namespace, and escaped examples; done when the requested XPath-compatible behavior is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.