

Lisp as a replacement for XML -- any ideas? - mojuba

If I want to use Lisp syntax to store tree-like data structures (as a replacement for XML), are there any libraries, standards, or just ideas how to do it?
======
gibsonf1
Here's how we do it:

("as_2586" ("as_2587" ("as_2588" ("as_2637" ("as_2638" ("as_2639"))
("as_2640")) ("as_2595")) ("as_2589")))

Equals:

Sub Projects

    
    
        * 200705_PSC_Trinity (Construction)
              o as_2587 (Client Approval)
                    + as_2588 (Building Permit)
                          # CD Set (Deliverable)
                                * A-110 (Deliverable)
                                      o 1. Site Plan (Deliverable)
                                * PSC Survey Info (Building Surveying)
                          # as_2595 (Systems Coordination)
                    + as_2589 (Programming)

~~~
mojuba
I don't quite get it -- can you show an example with tags, attributes and
text?

~~~
gibsonf1
I just showed the hierarchy structure. You can put anything you want in the
nodes of the hierarchy. In the example, these are object names that then
generate the example hierarchy below in our application. Hope this helps.

------
bitwize
Until all Lisps standardize on Unicode (at least UTF-8 and UTF-16), Lisp will
never replace XML. It's been slow going just getting Unicode _support_ into
Lisps, let alone having internal data structures (symbols, etc.) represented
in Unicode.

------
jkush
Read this essay for some ideas:

<http://www.defmacro.org/ramblings/lisp.html>

------
edu
I think you can do it directly. No? I've just started to study List, but I
think you could do sth like:

    
    
      '(root (child-1 attr1: val1 attr2: val2)
             (child-2 attr1: val1 attr2: val2)
             (child-3 attr1: val1 attr2: val2))
    

And then recurse over it?

BTW, If I'm wrong please teach me :D

------
brlewis
XML and Scheme <http://okmij.org/ftp/Scheme/xml.html>

------
marketer
You're just replacing the data storage. XML has a lot more features, like
schema validation and querying.

~~~
mojuba
True, but syntax doesn't matter, I think. Everything can be re-defined in Lisp
style if needed.

What I'm looking for is a clearly defined syntax, character sets,
metachchacters, etc for Lisp-like representation of data.

~~~
dpapathanasiou
_syntax doesn't matter, I think. Everything can be re-defined in Lisp style if
needed._

Yes, you're right.

You might be interested in this:
<http://www.pmsf.de/resources/lisp/expat.html>

If you use Mai's modified expat, you can convert any feed into s-expressions,
preserving all attributes and namespaces.

Here's a quick example.

This is the beginning of the xml for the news.yc feed:

<rss version="2.0"><channel><title>Startup
News</title><link>[http://news.ycombinator.com</link><description&#...](http://news.ycombinator.com</link><description>The)
most interesting startup-related links, as determined by
readers.</description><item><title>PG: If starting viaweb today, would you use
lisp?</title><link>[http://news.ycombinator.com/item?id=36905</link><...](http://news.ycombinator.com/item?id=36905</link><comments>http://news.ycombinator.com/item?id=36905</comments></item>);

And here's the expat-parsed, s-expression:

(("rss" "version" "2.0")(("channel")(("title")"Startup
News")(("link")"<http://news.ycombinator.com>")(("description")"The most
interesting startup-related links, as determined by
readers.")(("item")(("title")"PG: If starting viaweb today, would you use
lisp?")(("link")"<http://news.ycombinator.com/item?id=36905>")(("comments")"<http://news.ycombinator.com/item?id=36905>"))

~~~
mojuba
Thanks.

I wonder if quotes can be omitted to make it slightly more readable. Anyway,
this idea obviously needs some effort for improvement before it can be brought
to market, so to say.

