That has many great ideas, and I like that they add delimiters. It was a valuable excercise. But its premise, 100% round-tripping with JSON, is the opposite of mine.
Round-tripping with XML, JSON, or anything else is explicitly a non-goal, though it is not an anti-goal in the sense that the FtanML designers were forbidden to do so.
And what does FtanML show, really? That when you do attempt a JSON with XML delimiters, you dont get a thing that looks like XML (or which existing XML systems could support with trivial tweaks) much anyway.
Actually it isn't. The value types null, boolean, string, and list are shared (and can be round-tripped through XML using xsi:null and xsi:type). However, there is no JSON equivalent to a FtanML rich-text value (it is not the same as a list of strings-and-elements). Furthermore, although a FtanML element can emulate a JSON object, it extends one in three ways:
- an optional name: no JSON equivalent, XML element names are required.
- an optional content value: no JSON equivalent, XML equivalents are element content (a list of FtanML elements), mixed content (a FtanML rich-text object), or empty content (leave the content out).
- attribute values can be any value, not just strings as in JSON or XML.
The last two points greatly simplify the RELAX NG style schema language, FtanGram, making it look more like Examplotron, as well as the XSLT analogue, FtanSkrit. For example, here is part of the FtanGram schema for a FtanML version of the infamous purchase-order example:
<element form=<purchaseOrder
shipTo=<addressType>
billTo=<addressType>
comment=<nullable<text elements=<inlineType>>>
items=<occurs=[1,] <itemType>>
>
This declares the constraints on an element named purchaseOrder, namely that:
- its shipTo and billTo attributes are of type addressType (an element whose schema is given elsewhere);
- it has a comment attribute which can be null (same as being omitted) or can have rich text whose elements are of the inlineType type (defined elsewhere either italic or bold elements) as its value;
- an item that occurs 1 or more times of type itemType, which is a list of one or more anonymous elements containing various attributes,
Note that everything in purchaseOrder is an attribute, because why not? Order doesn't matter here. In XML and JSON that's impossible, because attribute values are restricted to strings.