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?
6 comments
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
("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)I don't quite get it -- can you show an example with tags, attributes and text?
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.
attributes 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.
Read this essay for some ideas:
http://www.defmacro.org/ramblings/lisp.html
http://www.defmacro.org/ramblings/lisp.html
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.
XML and Scheme
http://okmij.org/ftp/Scheme/xml.html
You're just replacing the data storage. XML has a lot more features, like schema validation and querying.
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.
What I'm looking for is a clearly defined syntax, character sets, metachchacters, etc for Lisp-like representation of data.
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... 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><...;
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"))
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... 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><...;
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"))
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.
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.
I think you can do it directly. No? I've just started to study List, but I think you could do sth like:
BTW, If I'm wrong please teach me :D
'(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