-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support document-oriented XML #7
Comments
@nichtich I'm a bit confused. In your snippet there, is that actually the syntax of MicroXML, or is that just the representation of it in JSON? The link you provided says:
This lead me to think that MicroXML is simply a structure similar to XML, but with less features; but provides a different way to serialize it into JSON? |
MicroXML defines a simplified subset of XML and an encoding/serialization/representation in JSON. The current implementation of There is a third useful subset of XML with JSON encoding that does not differentiate between attribute names and element names, so there is no The sets of XML document that can be expressed in each XML model are proper subsets:
Full support is more relevant for reading XML documents because it needs to be decided which JSON structure the XML structure is mapped to. |
Ah ok I think I get it now. So this would involve adding an extra format as you said Then, the other side of things, doing The main challenge here would be the conversion of XML style format into JSON to pass to |
Given this input document <root><x a="1"><a>2</a></x><y b="3">4</y></root> I'd expect {
"x": { "@a": "1", "a": "2" },
"y": { "@b": "3", "#text": "4" }
} and {
"x": { "a": [ "1", "2" ] },
"y": { "b": "3", "#text": "4" }
} and [ "root", {}, [
[ "x", { "a": "1" }, [ [ "a", {}, ["2" ] ] ] ],
[ "y", { "b": "3" }, [ "4" ] ]
] ] I'd silently ignore all character data in mixed content elements for input format |
@nichtich Just to confirm this before I get too far in; EDIT: Currently my implementation works like (with the input from your example) oq -i mxml .
[
"root",
{},
[
[
"x",
{
"a": "1"
},
[
[
"a",
{},
[
"2"
]
]
]
],
[
"y",
{
"b": "3"
},
[
"4"
]
]
]
] oq -i mxml -o mxml .
<?xml version="1.0" encoding="UTF-8"?>
<root>
<x a="1">
<a>2</a>
</x>
<y b="3">4</y>
</root> I'm assuming it wouldn't be expected that you could read in an |
The XML encoding in JSON used by oq (described here, it should have a name) does not preserve element order in mixed-content XML elements -- therefore oq only supports a subset of XML. This makes sense for most applications where XML is used in a similar way like JSON and YAML. Full support of XML (minus less used features such as DTD that happed to be part of the XML specification) should be possible nevertheless. The XML encoding in JSON to do so is MicroXML. How about this:
mxml
(akamicroxml
)An example from your blog post in MicroXML:
The text was updated successfully, but these errors were encountered: