The Artima Developer Community
Sponsored Link

Heron-Centric: Ruminations of a Language Designer
Presenting a Simpler Alternative to XML: PicoML
by Christopher Diggins
November 2, 2005
Summary
I have devised a simple mark-up scheme for my own purposes which is much simpler than XML.

Advertisement

If you have ever looked at the official XML specification then you know that as far as mark-up languages go, it is far more complicated than it needs to be. Writing an XML parser is supposed to be easy, but in practice is very hard to do correctly. This is a great example of how bad things get when technology is designed by committee.

Anyway, enough bitching. I currently need a simple and efficient markup language to represent textual data with a hierarchical structure, and I came up with the following format I'm calling PicoML:

  document ::=
    "[#picoml]" tagged_content

  tagged_content ::=
    open_tag content close_tag

  content ::=
    text? (tagged_content | text)*

  open_tag ::=
    "[" text "]"

  close_tag ::=
    "[/]"

  text ::=
    ^("]" | "[" | "/" | "\") | escaped_char

  escaped_char ::=
    "\[" | "\/" | "\]" | "\\"
And that is literally it! No attributes, no entities, no DTD's, no B.S. Just a compact, and easily parsed markup language.

It is trivial to map an XML document to PicoML. Take for instance the following XML:

  <cd>
  <title>Maggie May</title>
  <artist>Rod Stewart</artist>
  <country>UK</country>
  <company>Pickwick</company>
  <price>8.50</price>
  <year>1990</year>
  </cd>
This becomes in PicoML:
  [cd]
  [title]Maggie May[/]
  [artist]Rod Stewart[/]
  [country]UK[/]
  [company]Pickwick[/]
  [price]8.50[/]
  [year]1990[/]
  [/]
If someone goes around stuffing data in attributes (and violating the spirit of XML), the mapping is still trivial:
  <stupid fu="bar"/>
becomes the following:
  [stupid][fu]bar[/][/]
In fact I think there is a relatively trivial XSLT to do the mapping automatically. So who else is tired of looking at an emperor with no clothing?

Talk Back!

Have an opinion? Readers have already posted 25 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Christopher Diggins adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Christopher Diggins is a software developer and freelance writer. Christopher loves programming, but is eternally frustrated by the shortcomings of modern programming languages. As would any reasonable person in his shoes, he decided to quit his day job to write his own ( www.heron-language.com ). Christopher is the co-author of the C++ Cookbook from O'Reilly. Christopher can be reached through his home page at www.cdiggins.com.

This weblog entry is Copyright © 2005 Christopher Diggins. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us