4 ms·
Lisp as a replacement for XML -- any ideas?
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 19y agoHere'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 19y agoI don't quite get it -- can you show an example with tags, attributes and text?
- gibsonf1 19y agoI 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.
- ryantmulligan 19y agoattributes are a red herring in XML. attributes could just as easily be expressed as a child called attributes, or just by listing the attributes as children.
- marketer 19y agoYou're just replacing the data storage. XML has a lot more features, like schema validation and querying.
- mojuba 19y agoTrue, 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 19y agosyntax 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 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>The http://news.ycombinator.com</link><description&#... 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><comments>http://news.ycombinator.com/item?id=36905</comments></item> http://news.ycombinator.com/item?id=36905</link><...; And here's the expat-parsed, s-expression: (("rss" "version" "2.0")(("channel")(("title")"Startup News")(("link")"http://news.ycombinator.com 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 http://news.ycombinator.com/item?id=36905")(("comments")"http://news.ycombinator.com/item?id=36905 http://news.ycombinator.com/item?id=36905"))
- mojuba 19y agoThanks. 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.
- brlewis 19y agoXML and Scheme http://okmij.org/ftp/Scheme/xml.html http://okmij.org/ftp/Scheme/xml.html
- jkush 19y agoRead this essay for some ideas: http://www.defmacro.org/ramblings/lisp.html http://www.defmacro.org/ramblings/lisp.html
- edu 19y agoI 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
- bitwize 19y agoUntil 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.