XNM - Xnm is Not a Markup language
Downloads: SourceForge download files
API's documentation
About XNM
The prevailing meta-format used today for serialization is XML. XML
was originally written as a markup language, and as such its original
intent was to add additional information to free flowing text. This is
indeed what is needed in the context of text markup, e.g. for a web
page or a word processor program. But using XML for general purpose
object serialization generates very verbose serialization that are way
larger than necessary.
Another shortcoming of XML is that there still is no support for
binary objects. This again is partly based in its markup roots.
It was with this in mind that XNM was created. Its design philosophy is:
- Recursively defined.
- Map to the scalar/table/hash structures of perl/python/ruby
- Not limited by preexisting language formats (JSON).
- Short, consise, visually appealing. Low signal to noise.
- No need to quote keys or one word values.
- Support binary data.
- Tables are enclosed by { } , arrays by [ ].
Examples of XNM
The following example shows a simple program configuration file:
fontsize: 16
fonts: { roman: Sans
italic: "Sans Italic"
bold: "Sans bold"
}
path: ["/usr/bin" "/bin" "/usr/local/bin"]
Here is another example copied from the wikipedia json page:
firstName: John
lastName: Smith
address: {
city: "New York, NY"
zipCode: 10021
streetAddress: "21 2nd Street"
}
phoneNumbers: [
"212 732-1234"
"646 123-4567"
]
The main (only) differences to JSON are:
- Single words don't need quotes
- Commas are not used between key/value pairs
Here is a third example translated from the gaim prefs file:
core => {
away => {
idle_reporting=>system
away_when_idle=>0
mins_before_way=>10
auto_reply=>awayidle
report_idle=>1
}
buddies => {}
contact => {
last_match => 0
offline_score => 2
away_score => 2
idle_score => 1
}
gaim => {
gtk=> {
browsers=> {
place=>F
command=>"xterm -e lynx %s"
browser=>firefox
new_window=>F
}
plugins => [
'/usr/lib/gaim/gaimrc.so'
'/usr/lib/gaim/ssl-nss.so'
'/usr/lib/gaim/ssl.so'
]
}
}
}
Note that the separater character used between keys and values is =>
combination like in perl.
Future plans
- Binary values will be introduced that are written as follows:
face: <size=12458 type="png">...12458 bytes follow...
- Interpolation when in double quotes:
dir: "/home/foo"
file: "$dir/foo"
bar: {
baz: 3
foo: "$dir/baz"
woz: {
dir "/home/waz"
waz: "$dir/maz" # Should use definition of innermost scope
}
}
Comments to: Dov Grobgeld <dov.grobgeld (a) gmail.com> - Last modified Sat 2007-01-13 23:51