[racket] sxml vs xexprs

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Sat Feb 19 13:25:29 EST 2011

I'm in a work crunch, so any responses to this I regret I'll probably 
have to review later rather than immediately.

John Clements wrote at 02/19/2011 12:59 PM:
> What are the advantages and disadvantages of SXML vs. xexprs? I've googled for this, but none of the high-ranked hits attempt to actually catalog their relative virtues.

Well, in light of Jay's recent changes to "web-server", I've actually 
abandoned my attempt to make a standard that unifies SXML and xexprs, 
and have moved my as-yet-unreleased new XML and HTML tools to support 
standard SXML with a few extensions.

I don't recall any relative strengths of xexprs, other than: (1) better 
support in "web-server" at the moment; (2) easier to implement 
traversals because you don't have to handle nested and redundant lists; 
(3) more terse representation for entity references, which I've done 
even better in one of my new extensions to SXML.

> parsing : I get the sense that the SXML parser is way more general, but it's not clear to me when this is useful.

The main SXML parser (Oleg Kiselyov's SSAX) is a great parser.  The 
handling of namespaces is important for rigorous and correct parsing of 
commonplace real-world XML.  Oleg has also gone through XML minutiae and 
addressed it.  SSAX also permits streaming parsing, providing a 
tree-fold interface, so you can handle inputs of arbitrary size.  I'm 
doing this for some new SXML tools of mine.  In preparation, I 
implemented a JSON parser using a tree-fold approach: 

> representation choices: the SXML choice (@ for attrs) seems less error-prone, though the choice of '@' is really unfortunate when I want to abstract using the 'at-exp' languages.

I slightly wish that "@" had been "=".  Not only has RnRS made "@" using 
as a symbol problematic, but "=" can be typed unshifted on my keyboard, 
:) and "=" is the same character used in XML.  I have been tempted to 
make all my tools support "=" as an alternative to "@", defaulting to 
"@" for interoperability with tools like SXPath and SSAX.

Regarding the original SSAX/SXML tools by Oleg, Kirill Lisovsky, and 
Dmitry Lizorkin, it looks like probably we will be making new PLaneT 
packages for them that tweak the tools to work better with Racket, such 
as doing exn:fail exceptions and having Racket documentation.  However, 
as part of being a good Scheme community citizen, as well as deferring 
to Oleg's leadership on SXML, it is my intention that these PLaneT 
packages track the upstream version, so I do not intend to implement any 
of my extensions directly to those packages.  Any SXML extensions will 
be submitted for consideration to upstream, and we'll see whether they 
are accepted.


Posted on the users mailing list.