article section: SXML, the Lisp approach

Article isn’t writing. Although, in general, I have ideas what to write, the actual writing is painfully slow. Today I’ve only finish a section, and I feel I’ll rewrite it somewhen.

SXML, the Lisp approach

Lisp is a family of computer languages. The most popular
dialects are Common Lisp (ref) and Scheme(ref).
In Lisp, data is representing in so-called S-expressions(ref),
or Symbolic Expressions, or "sexps", defined recursively.

Just as XML, S-expressions can represent any data structures,
including hierarchical, and Lisp is good in processing them.
There are a lot of discussions on comparing S-expressions,
Lisp and XML (for example, see ref and ref). In our work
we use a combination of useful features of XML and Lisp worlds.

The most developed Lisp approach for XML processing is the
SXML(ref) library for Scheme. It defines an XML representation
in terms of S-expressions and provides a growing number of tools.

The SXML format uses lists to represent an XML tree. In each list,
the first symbol is the name of an XML element node, and other
list items are the children of the node. There is a set of
special symbols to specify non-element XML nodes. For example,
list of attributes is stored under the special symbol "@".

Here is the SXML representation of the sample XML document:

(article (@ (id "hw"))
 (title "Hello")
 (para  "Hello " (object "World") "!"))

Some XML standards are adopted for SXML. For example, there is
SSAX(ref), an XML parser in Scheme with SAX(ref) interface,
SXPath(ref), an analogue of XPath, STX(ref), a compiler for a subset
of XSLT, and there is possibility for (X)Querying XML in Scheme(ref).

A useful feature of SXML tools is possibility to mix processing
enforced by a standard with procesing in Scheme. It can be used
to write more expressive programs. For example, the paper "SXSLT,
manipulation language for SXML"(ref) demonstrated practical
tasks for which SXSLT suits better than XSLT.

While most of the SXML tools are just analogues of XML standards,
some core XML standards are implemented without deviations. Among
these tools are an XML parser and the txpath(ref) library for
XPath processing.

Leave a Reply