From 46b2d2290ddf511335af23d4e2bf312a80fc7afa Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Sun, 27 Sep 2020 12:39:32 +0300 Subject: [PATCH] Add files --- .gitignore | 1 + Dockerfile | 8 ++++ Makefile | 5 +++ config.xml | 22 ++++++++++ config.xsd | 37 +++++++++++++++++ convert.sh | 22 ++++++++++ converted/Abdera/config.json | 1 + converted/Abdera/pretty.json | 62 ++++++++++++++++++++++++++++ converted/BadgerFish/config.json | 1 + converted/BadgerFish/pretty.json | 71 ++++++++++++++++++++++++++++++++ converted/Columnar/config.json | 1 + converted/Columnar/pretty.json | 50 ++++++++++++++++++++++ converted/JsonML/config.json | 1 + converted/JsonML/pretty.json | 70 +++++++++++++++++++++++++++++++ converted/Parker/config.json | 1 + converted/Parker/pretty.json | 27 ++++++++++++ converted/Unordered/config.json | 1 + converted/Unordered/pretty.json | 49 ++++++++++++++++++++++ 18 files changed, 430 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 config.xml create mode 100644 config.xsd create mode 100755 convert.sh create mode 100644 converted/Abdera/config.json create mode 100644 converted/Abdera/pretty.json create mode 100644 converted/BadgerFish/config.json create mode 100644 converted/BadgerFish/pretty.json create mode 100644 converted/Columnar/config.json create mode 100644 converted/Columnar/pretty.json create mode 100644 converted/JsonML/config.json create mode 100644 converted/JsonML/pretty.json create mode 100644 converted/Parker/config.json create mode 100644 converted/Parker/pretty.json create mode 100644 converted/Unordered/config.json create mode 100644 converted/Unordered/pretty.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b561106 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.8.5-alpine + +RUN pip install -Iv xmlschema==1.2.4 + +RUN mkdir -p /data + +WORKDIR /data + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1fa1b72 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +build: + docker build -t xmlschema-python . + +convert: + ./convert.sh diff --git a/config.xml b/config.xml new file mode 100644 index 0000000..a3870ab --- /dev/null +++ b/config.xml @@ -0,0 +1,22 @@ + + + + Item + + + money + 100 + + + item + 2 + 5 + + + + + Item 2 + item + 12345 + + diff --git a/config.xsd b/config.xsd new file mode 100644 index 0000000..972aa56 --- /dev/null +++ b/config.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/convert.sh b/convert.sh new file mode 100755 index 0000000..dcfea4e --- /dev/null +++ b/convert.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -eux -o pipefail + +converters=( Unordered Parker BadgerFish Abdera JsonML Columnar ) + +for i in "${converters[@]}" +do + echo "$i" + + mkdir -p "converted/$i" + + docker run -it \ + -v "$PWD:/data" \ + -u "$(id -u):$(id -g)" \ + xmlschema-python \ + xmlschema-xml2json \ + config.xml --converter "$i" --output "converted/$i" --force + + jq -r . "converted/$i/config.json" > "converted/$i/pretty.json" +done + diff --git a/converted/Abdera/config.json b/converted/Abdera/config.json new file mode 100644 index 0000000..d8a1ef3 --- /dev/null +++ b/converted/Abdera/config.json @@ -0,0 +1 @@ +{"attributes": {"xsi:noNamespaceSchemaLocation": "config.xsd"}, "children": [{"item": [{"attributes": {"id": 1234}, "children": [{"name": "Item", "award": {"resource": [{"attributes": {"type": "money"}, "children": [{"type": "money", "count": 100}]}, {"attributes": {"type": "item"}, "children": [{"type": "item", "count": 2, "itemId": 5}]}]}}]}, {"attributes": {"id": 1235}, "children": [{"name": "Item 2", "alias": ["item", "12345"]}]}]}]} \ No newline at end of file diff --git a/converted/Abdera/pretty.json b/converted/Abdera/pretty.json new file mode 100644 index 0000000..ccbc2bc --- /dev/null +++ b/converted/Abdera/pretty.json @@ -0,0 +1,62 @@ +{ + "attributes": { + "xsi:noNamespaceSchemaLocation": "config.xsd" + }, + "children": [ + { + "item": [ + { + "attributes": { + "id": 1234 + }, + "children": [ + { + "name": "Item", + "award": { + "resource": [ + { + "attributes": { + "type": "money" + }, + "children": [ + { + "type": "money", + "count": 100 + } + ] + }, + { + "attributes": { + "type": "item" + }, + "children": [ + { + "type": "item", + "count": 2, + "itemId": 5 + } + ] + } + ] + } + } + ] + }, + { + "attributes": { + "id": 1235 + }, + "children": [ + { + "name": "Item 2", + "alias": [ + "item", + "12345" + ] + } + ] + } + ] + } + ] +} diff --git a/converted/BadgerFish/config.json b/converted/BadgerFish/config.json new file mode 100644 index 0000000..49031d2 --- /dev/null +++ b/converted/BadgerFish/config.json @@ -0,0 +1 @@ +{"@xmlns": {"xsi": "http://www.w3.org/2001/XMLSchema-instance"}, "items": {"@xsi:noNamespaceSchemaLocation": "config.xsd", "item": [{"@id": 1234, "name": [{"$": "Item"}], "award": [{"resource": [{"@type": "money", "type": [{"$": "money"}], "count": [{"$": 100}]}, {"@type": "item", "type": [{"$": "item"}], "count": [{"$": 2}], "itemId": [{"$": 5}]}]}]}, {"@id": 1235, "name": [{"$": "Item 2"}], "alias": [{"$": "item"}, {"$": "12345"}]}]}} \ No newline at end of file diff --git a/converted/BadgerFish/pretty.json b/converted/BadgerFish/pretty.json new file mode 100644 index 0000000..409c831 --- /dev/null +++ b/converted/BadgerFish/pretty.json @@ -0,0 +1,71 @@ +{ + "@xmlns": { + "xsi": "http://www.w3.org/2001/XMLSchema-instance" + }, + "items": { + "@xsi:noNamespaceSchemaLocation": "config.xsd", + "item": [ + { + "@id": 1234, + "name": [ + { + "$": "Item" + } + ], + "award": [ + { + "resource": [ + { + "@type": "money", + "type": [ + { + "$": "money" + } + ], + "count": [ + { + "$": 100 + } + ] + }, + { + "@type": "item", + "type": [ + { + "$": "item" + } + ], + "count": [ + { + "$": 2 + } + ], + "itemId": [ + { + "$": 5 + } + ] + } + ] + } + ] + }, + { + "@id": 1235, + "name": [ + { + "$": "Item 2" + } + ], + "alias": [ + { + "$": "item" + }, + { + "$": "12345" + } + ] + } + ] + } +} diff --git a/converted/Columnar/config.json b/converted/Columnar/config.json new file mode 100644 index 0000000..82c8c8f --- /dev/null +++ b/converted/Columnar/config.json @@ -0,0 +1 @@ +{"items": {"itemsxsi:noNamespaceSchemaLocation": "config.xsd", "item": [{"itemid": 1234, "name": ["Item"], "award": [{"resource": [{"resourcetype": "money", "type": ["money"], "count": [100]}, {"resourcetype": "item", "type": ["item"], "count": [2], "itemId": [5]}]}]}, {"itemid": 1235, "name": ["Item 2"], "alias": ["item", "12345"]}]}} \ No newline at end of file diff --git a/converted/Columnar/pretty.json b/converted/Columnar/pretty.json new file mode 100644 index 0000000..578b488 --- /dev/null +++ b/converted/Columnar/pretty.json @@ -0,0 +1,50 @@ +{ + "items": { + "itemsxsi:noNamespaceSchemaLocation": "config.xsd", + "item": [ + { + "itemid": 1234, + "name": [ + "Item" + ], + "award": [ + { + "resource": [ + { + "resourcetype": "money", + "type": [ + "money" + ], + "count": [ + 100 + ] + }, + { + "resourcetype": "item", + "type": [ + "item" + ], + "count": [ + 2 + ], + "itemId": [ + 5 + ] + } + ] + } + ] + }, + { + "itemid": 1235, + "name": [ + "Item 2" + ], + "alias": [ + "item", + "12345" + ] + } + ] + } +} diff --git a/converted/JsonML/config.json b/converted/JsonML/config.json new file mode 100644 index 0000000..916a286 --- /dev/null +++ b/converted/JsonML/config.json @@ -0,0 +1 @@ +["items", {"xsi:noNamespaceSchemaLocation": "config.xsd", "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"}, ["item", {"id": 1234}, ["name", "Item"], ["award", ["resource", {"type": "money"}, ["type", "money"], ["count", 100]], ["resource", {"type": "item"}, ["type", "item"], ["count", 2], ["itemId", 5]]]], ["item", {"id": 1235}, ["name", "Item 2"], ["alias", "item"], ["alias", "12345"]]] \ No newline at end of file diff --git a/converted/JsonML/pretty.json b/converted/JsonML/pretty.json new file mode 100644 index 0000000..3d74e6a --- /dev/null +++ b/converted/JsonML/pretty.json @@ -0,0 +1,70 @@ +[ + "items", + { + "xsi:noNamespaceSchemaLocation": "config.xsd", + "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance" + }, + [ + "item", + { + "id": 1234 + }, + [ + "name", + "Item" + ], + [ + "award", + [ + "resource", + { + "type": "money" + }, + [ + "type", + "money" + ], + [ + "count", + 100 + ] + ], + [ + "resource", + { + "type": "item" + }, + [ + "type", + "item" + ], + [ + "count", + 2 + ], + [ + "itemId", + 5 + ] + ] + ] + ], + [ + "item", + { + "id": 1235 + }, + [ + "name", + "Item 2" + ], + [ + "alias", + "item" + ], + [ + "alias", + "12345" + ] + ] +] diff --git a/converted/Parker/config.json b/converted/Parker/config.json new file mode 100644 index 0000000..c9791de --- /dev/null +++ b/converted/Parker/config.json @@ -0,0 +1 @@ +{"item": [{"name": "Item", "award": {"resource": [{"type": "money", "count": 100}, {"type": "item", "count": 2, "itemId": 5}]}}, {"name": "Item 2", "alias": ["item", "12345"]}]} \ No newline at end of file diff --git a/converted/Parker/pretty.json b/converted/Parker/pretty.json new file mode 100644 index 0000000..3cef210 --- /dev/null +++ b/converted/Parker/pretty.json @@ -0,0 +1,27 @@ +{ + "item": [ + { + "name": "Item", + "award": { + "resource": [ + { + "type": "money", + "count": 100 + }, + { + "type": "item", + "count": 2, + "itemId": 5 + } + ] + } + }, + { + "name": "Item 2", + "alias": [ + "item", + "12345" + ] + } + ] +} diff --git a/converted/Unordered/config.json b/converted/Unordered/config.json new file mode 100644 index 0000000..ada20c4 --- /dev/null +++ b/converted/Unordered/config.json @@ -0,0 +1 @@ +{"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "@xsi:noNamespaceSchemaLocation": "config.xsd", "item": [{"@id": 1234, "name": ["Item"], "award": [{"resource": [{"@type": "money", "type": ["money"], "count": [100]}, {"@type": "item", "type": ["item"], "count": [2], "itemId": [5]}]}]}, {"@id": 1235, "name": ["Item 2"], "alias": ["item", "12345"]}]} \ No newline at end of file diff --git a/converted/Unordered/pretty.json b/converted/Unordered/pretty.json new file mode 100644 index 0000000..5a72fe9 --- /dev/null +++ b/converted/Unordered/pretty.json @@ -0,0 +1,49 @@ +{ + "@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", + "@xsi:noNamespaceSchemaLocation": "config.xsd", + "item": [ + { + "@id": 1234, + "name": [ + "Item" + ], + "award": [ + { + "resource": [ + { + "@type": "money", + "type": [ + "money" + ], + "count": [ + 100 + ] + }, + { + "@type": "item", + "type": [ + "item" + ], + "count": [ + 2 + ], + "itemId": [ + 5 + ] + } + ] + } + ] + }, + { + "@id": 1235, + "name": [ + "Item 2" + ], + "alias": [ + "item", + "12345" + ] + } + ] +}