Several examples could make clear what it looks like...
This is the simple XML:
<note>
<from>Pooh</from>
<to>Bee</to>
<posted>2006-08-15T17:30</posted>
<heading>Honey</heading>
Don't forget to get me honey!
</note>
And there are it's formatted and compact versions in AXON:
note {
from: "Pooh"
to: "Bee"
posted: 2006-08-15T17:30
heading: "Honey"
"Don't forget to get me honey!" }
note{to:"Bee" from:"Pooh" posted:2006-08-15T17:30 heading:"Honey" "Don't forget to get me honey!"}
and without braces but with indentations like in YAML:
note:
from: "Pooh"
to: "Bee"
posted: 2006-08-15T17:30
heading: "Honey"
"Don't forget to get me honey!"
These AXON representations are sematically equivalent to the XML original representation. All explicitlty denote the name of the object (note), attributes (from, to, posted, heading) and child value ("Don't forget to get me honey!").
JSON style of representation is also possible in AXON:
{note: {
from: "Pooh"
to: "Bee"
posted: 2006-08-15T17:30
heading: "Honey"
body: "Don't forget to get me honey!"
}}
{note:{from:"Pooh" to:"Bee" posted:2006-08-15T17:30 heading:"Honey" body:"Don't forget to get me honey!"}}
JSON could be considered almost as subset of AXON.
Let's consider basic example:
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
There is a simple translation to AXON by removing double quotes (") around the identifier-like keys and commas (,):
{ menu: {
id: "file"
value: "File"
popup: {
menuitem: [
{value: "New" "onclick": "CreateNewDoc()"}
{value: "Open" "onclick": "OpenDoc()"}
{value: "Close" "onclick": "CloseDoc()"}
]
}
}}
AXON could be also considered as extension of JSON that supports datetime and crossreferences:
{
topic: [
&1 {python: "Python related"}
&2 {axon: "AXON related"}
&3 {json: "JSON related"}
]
posts: [
{ id: 1
topic: *1
date: 2012-01-02T12:15+03
body:"..." }
{ id: 2
topic: *2
date: 2012-01-12T09:25+03
body:"..." }
{ id: 3
topic: *3
date: 2012-02-08T10:35+03
body:"..." }
]
}
There was pointed many times that XML is for documents and JSON is for just data. Actually XML can't be bitten by JSON for documents with variable structure, especially when the order of elements is essential.
Let's consider example:
xhtml
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Form Example</title>
<link rel="stylesheet" href="formstyle.css" type="text/css" />
</head>
<body>
<h1>Form Example</h1>
<form action="sample.py">
<div class="formin"> (a)
<input type="text" name="text1" value="A textbox" />
</div>
<div class="formin"> (b)
<input type="text" size="6" maxlength="10" name="text2" />
</div>
<div class="formin"> (c)
<input type="submit" value="Go!" />
</div>
</form>
</body>
</html>
Tranlsation to AXON is looks like (in formatted form):
html {
xmlns:"http://www.w3.org/1999/xhtml"
head {
title {"Form Example"}
link {
rel:"stylesheet"
href: "formstyle.css"
type: "text/css" }
body {
h1 {"Form Example"}
form {
action: "sample.py"
div {
class: "formin"
"(a)"
input {type:"text" name:"text1" value:"A textbox"}}
div {
class: "formin"
"(b)"
input {type:"text" size:6 maxlength:10 name:"text2"}}
div {
class: "formb"
"(c)"
input {type:"submit" value:"Go!"}}
}
}
}
and in indented form without braces (like in YAML):
html:
xmlns: "http://www.w3.org/1999/xhtml"
head:
title:
"Form Example"
link:
rel: "stylesheet"
href: "formstyle.css"
type: "text/css"
body:
h1:
"Form Example"
form:
action: "sample.py"
div:
class: "formin"
"(a)"
input:
type:"text" name:"text1" value:"A textbox"
div:
class: "formin"
"(b)"
input:
type:"text" size:6 maxlength:10 name:"text2"
div:
class: "formb"
"(c)"
input:
type:"submit" value:"Go!"
One can see that it's easy to translate much of namespaceless XML documents to AXON without reorganization of the original document.
Note that this example isn't about representation of (X)HTML/XML in AXON. It's all about possibility of AXON to represent such type of documents that is difficult to do in JSON without of syntactic overhead.