25 Nov 2003 wspace   » (Journeyer)

If you *are* using indentation, why use XML?

The example by Linus:

    # This is an example
    myhost.com
        passwd Make1Up
        timeout 50

yourhost.com passwd Crappy4You timeout 0

instead of

    <!-- This is an example -->
    <host>myhost.com
       <passwd>Make1Up</passwd>
       <timeout>50</timeout>
    </host>

<host>yourhost.org <passwd>Crappy4You</passwd> <timeout>0</timeout> </host>

Agreed, much more readable. And parsing is no problem.

But the XML example is not using attributes, and his readable version doesn't have something like it either. The order of elements in a list is significant in XML; the order of attributes is not (it is a *set* of attributes). And you need to have 1 root element in XML.

I have been thinking a bit about it but I am still not sure what a good readable format would look like.

Perhaps

    # This is an example
    host protocol=http [myhost.com]
        passwd 
            type=secure 
            date=112503 
            [Make1Up\=nice]
        timeout 50

Every line has to start with an element, unless it is an attribute or text content of an element.
Attributes have an =.
Text content goes inside square braces, and may be on the same line as the "last" attribute.
Indentation of elements gives the tree structure: top down + indentation corresponds to the root-left-right traversal of the data tree.

But this format does not make clear that the order of attributes is irrelevant. So I am not happy with it yet.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!