Add files
This commit is contained in:
commit
46b2d2290d
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.idea/
|
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
FROM python:3.8.5-alpine
|
||||||
|
|
||||||
|
RUN pip install -Iv xmlschema==1.2.4
|
||||||
|
|
||||||
|
RUN mkdir -p /data
|
||||||
|
|
||||||
|
WORKDIR /data
|
||||||
|
|
5
Makefile
Normal file
5
Makefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
build:
|
||||||
|
docker build -t xmlschema-python .
|
||||||
|
|
||||||
|
convert:
|
||||||
|
./convert.sh
|
22
config.xml
Normal file
22
config.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="config.xsd">
|
||||||
|
<item id="1234">
|
||||||
|
<name>Item</name>
|
||||||
|
<award>
|
||||||
|
<resource type="money">
|
||||||
|
<type>money</type>
|
||||||
|
<count>100</count>
|
||||||
|
</resource>
|
||||||
|
<resource type="item">
|
||||||
|
<type>item</type>
|
||||||
|
<count>2</count>
|
||||||
|
<itemId>5</itemId>
|
||||||
|
</resource>
|
||||||
|
</award>
|
||||||
|
</item>
|
||||||
|
<item id="1235">
|
||||||
|
<name>Item 2</name>
|
||||||
|
<alias>item</alias>
|
||||||
|
<alias>12345</alias>
|
||||||
|
</item>
|
||||||
|
</items>
|
37
config.xsd
Normal file
37
config.xsd
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
|
||||||
|
|
||||||
|
<xs:element name="items">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence maxOccurs="unbounded">
|
||||||
|
<xs:element name="item" type="ItemType"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
|
||||||
|
<xs:complexType name="ItemType">
|
||||||
|
<xs:choice maxOccurs="unbounded">
|
||||||
|
<xs:element name="name" type="xs:string"/>
|
||||||
|
<xs:element name="limit" type="xs:integer"/>
|
||||||
|
<xs:element name="award" type="AwardType"/>
|
||||||
|
<xs:element name="alias" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
</xs:choice>
|
||||||
|
<xs:attribute name="id" type="xs:integer"/>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:complexType name="AwardType">
|
||||||
|
<xs:sequence maxOccurs="unbounded">
|
||||||
|
<xs:element name="resource" type="ResourceType"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:complexType name="ResourceType">
|
||||||
|
<xs:choice maxOccurs="unbounded">
|
||||||
|
<xs:element name="type" type="xs:string"/>
|
||||||
|
<xs:element name="count" type="xs:integer"/>
|
||||||
|
<xs:element name="itemId" type="xs:integer"/>
|
||||||
|
</xs:choice>
|
||||||
|
<xs:attribute name="type" type="xs:string"/>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
</xs:schema>
|
22
convert.sh
Executable file
22
convert.sh
Executable file
@ -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
|
||||||
|
|
1
converted/Abdera/config.json
Normal file
1
converted/Abdera/config.json
Normal file
@ -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"]}]}]}]}
|
62
converted/Abdera/pretty.json
Normal file
62
converted/Abdera/pretty.json
Normal file
@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1
converted/BadgerFish/config.json
Normal file
1
converted/BadgerFish/config.json
Normal file
@ -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"}]}]}}
|
71
converted/BadgerFish/pretty.json
Normal file
71
converted/BadgerFish/pretty.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
1
converted/Columnar/config.json
Normal file
1
converted/Columnar/config.json
Normal file
@ -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"]}]}}
|
50
converted/Columnar/pretty.json
Normal file
50
converted/Columnar/pretty.json
Normal file
@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
1
converted/JsonML/config.json
Normal file
1
converted/JsonML/config.json
Normal file
@ -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"]]]
|
70
converted/JsonML/pretty.json
Normal file
70
converted/JsonML/pretty.json
Normal file
@ -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"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
1
converted/Parker/config.json
Normal file
1
converted/Parker/config.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"item": [{"name": "Item", "award": {"resource": [{"type": "money", "count": 100}, {"type": "item", "count": 2, "itemId": 5}]}}, {"name": "Item 2", "alias": ["item", "12345"]}]}
|
27
converted/Parker/pretty.json
Normal file
27
converted/Parker/pretty.json
Normal file
@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1
converted/Unordered/config.json
Normal file
1
converted/Unordered/config.json
Normal file
@ -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"]}]}
|
49
converted/Unordered/pretty.json
Normal file
49
converted/Unordered/pretty.json
Normal file
@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user