TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Using s-expressions instead of XML

29 pointsby jazzdevover 15 years ago

5 comments

chover 15 years ago
I'll just leave this here: <a href="http://okmij.org/ftp/Scheme/xml.html" rel="nofollow">http://okmij.org/ftp/Scheme/xml.html</a>
评论 #1147200 未加载
loup-vaillantover 15 years ago
To simplify things a bit, I would suggest the use of angle brackets instead of parentheses:<p><pre><code> &#60;tagname &#60;@ attr "value" attr2 "value2"&#62; &#60;tagname2&#62; &#60;tagname3 "data"&#62;&#62; </code></pre> Going a bit further, we could require the `@`, and place it <i>after</i> the attributes list. This format has fewer special cases:<p><pre><code> &#60;tagname attr "value" attr2 "value2" @ &#60;tagname2 @&#62; &#60;tagname3 @"data"&#62;&#62; </code></pre> Finally, we could remove the quotes around the raw strings ("data"), while inverting the brackets:<p><pre><code> &#62;tagname attr "value" attr2 "value2" @ &#62;tagname2 @&#60; &#62;tagname3 @data&#60;&#60; </code></pre> This may look twisted, but we stay very close to true S-expressions, while using the same escape characters we have in plain XML.
评论 #1147796 未加载
评论 #1147744 未加载
评论 #1147642 未加载
vdmover 15 years ago
XML is not S-Expressions <a href="http://www.prescod.net/xml/sexprs.html" rel="nofollow">http://www.prescod.net/xml/sexprs.html</a>
urielover 15 years ago
Nice!<p>And a good time to remember Erik Naggum's epic S-exps vs. XML rant:<p><a href="http://harmful.cat-v.org/software/xml/s-exp_vs_XML" rel="nofollow">http://harmful.cat-v.org/software/xml/s-exp_vs_XML</a>
评论 #1147248 未加载
mojubaover 15 years ago
Can you easily filter raw text out of a Sexp stream? I don't think so. It would require a full Sexp machine to read and "understand" the tree, whereas with markup-style data streams it takes a trivial regexp to extract text. (Why would you need this? Search/indexing, for example.)
评论 #1148359 未加载
评论 #1148351 未加载
评论 #1147734 未加载