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 arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
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 (tree-structured) data. S-expressions were invented for and popularized by the programming la ...
s, to facilitate working with XML data in
Lisp A lisp is a speech impairment in which a person misarticulates sibilants (, , , , , , , ). These misarticulations often result in unclear speech. Types * A frontal lisp occurs when the tongue is placed anterior to the target. Interdental lisping ...
and
Scheme A scheme is a systematic plan for the implementation of a certain idea. Scheme or schemer may refer to: Arts and entertainment * ''The Scheme'' (TV series), a BBC Scotland documentary series * The Scheme (band), an English pop band * ''The Schem ...
. 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) and can be used to compute values (e.g., strings, numbers, or Boolean v ...
, 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, which may subseque ...
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 addition ...
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 IBM Developer is a global community of coders, developer advocates, and digital resources that help developers learn, build, and connect. The IBM Developer website (previously known as IBM developerWorks) hosts a wide range of resources, tools, a ...
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. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
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. We can also see that there's no need to "escape" otherwise meaningful characters like & and > as &amp; and &gt; entities. All string content is automatically escaped because it is considered to be pure content, and has no tags or entities in it. This also means it is much easier to insert autogenerated content and that there is no danger that we might forget to escape user input when we display it to other users (which could lead to all kinds of
cross-site scripting Cross-site scripting (XSS) is a type of security vulnerability that can be found in some web applications. XSS attacks enable attackers to inject client-side scripts into web pages viewed by other users. A cross-site scripting vulnerability may ...
attacks or other development annoyances).


References

{{reflist


External links


SXML Tools Tutorial by Dmitry Lizorkin

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