SXML
   HOME

TheInfoList



OR:

SXML is an alternative syntax for writing
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
data (more precisely, XML Infosets) as
S-expression In computer programming, an S-expression (or symbolic expression, abbreviated as sexpr or sexp) is an expression in a like-named notation for nested List (computing), list (Tree (data structure), tree-structured) data. S-expressions were invented ...
s, to facilitate working with XML data in
Lisp Lisp (historically LISP, an abbreviation of "list processing") is a family of programming languages with a long history and a distinctive, fully parenthesized Polish notation#Explanation, prefix notation. Originally specified in the late 1950s, ...
and Scheme. An associated suite of tools implements
XPath XPath (XML Path Language) is an expression language designed to support the query or transformation of XML documents. It was defined by the World Wide Web Consortium (W3C) in 1999, and can be used to compute values (e.g., strings, numbers, or ...
, SAX and
XSLT XSLT (Extensible Stylesheet Language Transformations) is a language originally designed for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text, or XSL Formatting Objects. These formats c ...
for SXML in Scheme and are available in the
GNU Guile GNU Ubiquitous Intelligent Language for Extensions (GNU Guile) is the preferred extension language system for the GNU Project and features an implementation of the programming language Scheme. Its first version was released in 1993. In additio ...
implementation of that language. Textual correspondence between SXML and XML for a sample XML snippet is shown below: Compared to other alternative representations for XML and its associated languages, SXML has the benefit of being directly parsable by existing Scheme implementations. The associated tools and documentation were praised in many respects by David Mertz in his IBM developerWorks column, though he also criticized the preliminary nature of its documentation and system.


Example

Take the following simple
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages which mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, pr ...
page: An example page

Hi, there!

This is just an ">>example<<" to show XHTML & SXML.

After translating it to SXML, the same page now looks like this: (*TOP* (@ (*NAMESPACES* (x "http://www.w3.org/1999/xhtml"))) (x:html (@ (xml:lang "en") (lang "en")) (x:head (x:title "An example page")) (x:body (x:h1 (@ (id "greeting")) "Hi, there") (x:p "This is just an \">>example<<\" to show XHTML & SXML.")))) Each element's tag pair is replaced by a set of parentheses. The tag's name is not repeated at the end, it is simply the first symbol in the list. The element's contents follow, which are either elements themselves or strings. There is no special syntax required for XML attributes. In SXML they are simply represented as just another node, which has the special name of @. This can't cause a name clash with an actual "@" tag, because @ is not allowed as a tag name in XML. This is a common pattern in SXML: anytime a tag is used to indicate a special status or something that is not possible in XML, a name is used that does not constitute a valid XML identifier. In SXML strings there are two characters that must be escaped, the " string delimiter (with \") and the \ escape symbol itself (with \\). The XML code above requires escaping three: & , < and > (with &amp; ,&lt;and &gt; respectively).


References

{{reflist


External links


SXML Tools Tutorial by Dmitry Lizorkin

SXML package for Racket
Markup languages Technical communication Scheme (programming language)