SXML - Motivation

Motivation

XML data processing languages suggested by the W3 Consortium, such as XPath, XSLT, XQuery (without XQuery Scripting) etc., like SQL in the relational database field, are not general-purpose programming languages and are thus not sufficient for implementing complete applications. For this reason, most XML applications are implemented by means of traditional programming languages, such as C and Java; or scripting languages, for example, Perl, JavaScript and Python.

An attempt to combine two different languages (for example, XPath and Java) leads to a problem known as impedance mismatch. Impedance mismatch problem consists of two aspects:

  • Different data models. E.g. XPath models an XML document as a tree, while most general purpose programming languages have no native data types for a tree.
  • Different programming paradigms. Say, XSLT is a functional language, while Java is object-oriented, and Perl is a procedural one.

Impedance mismatch requires complicated converters and APIs (for example, DOM) to be used for combining such two languages.

Impedance mismatch problem can be reduced and even eliminated using the Scheme functional programming language for XML data processing

  • Nested lists (S-expressions in Scheme) provide a natural representation for nested XML documents. Scheme represents its code and data as nested lists of dynamically typed elements. XML document, being a hierarchical structure of nested XML elements, can be thought of as a hierarchical nested Scheme list (so-called S-expression).
  • Scheme is a functional language, as most XML-languages are (e.g. XSLT and XQuery). Scheme processes (nested) lists in a recursive manner which can be thought of as traversing/transforming the document tree.

Scheme, being a Lisp dialect, is a widely recognized scripting language. It is one of the most elegant and compact programming languages practically used: the description of Scheme standard consists of 40 pages only. Scheme is a high-level programming language, suitable for fast prototyping. Moreover, Scheme programs are generally several times more compact than the equivalent C programs.

XML and SXML textual notations are much alike: informally, SXML replaces XML start/end tags with opening/closing brackets. On the other hand, SXML is an S-expression and thus maps trivially to and from the main data structure for Scheme programming language. Consequently SXML can be easily and naturally processed via Scheme.

Read more about this topic:  SXML

Famous quotes containing the word motivation:

    Self-determination has to mean that the leader is your individual gut, and heart, and mind or we’re talking about power, again, and its rather well-known impurities. Who is really going to care whether you live or die and who is going to know the most intimate motivation for your laughter and your tears is the only person to be trusted to speak for you and to decide what you will or will not do.
    June Jordan (b. 1939)