1 SXML

SXML is a representation of XML elements using s-expressions. The following grammar describes the structure of SXML:

  top = 
(*TOP* maybe-annotations
       PI ...
       comment ...
       element)
     
  element = (name maybe-annot-attributes child ...)
     
  annot-attributes = (@ attribute ... maybe-annotations)
     
  attribute = (name maybe-value maybe-annotations)
     
  child = element
  | character-data-string
  | PI
  | comment
  | entity
     
  PI = 
(*PI* pi-target
      maybe-annotations
      processing-instruction-content-string)
     
  comment = (*COMMENT* comment-string)
     
  entity = (*ENTITY* public-id-string system-id-string)
     
  name = local-name
  | exp-name
     
  local-name = symbol conforming to XML Namespace recommendation
     
  exp-name = symbol of the form namespace-id:local-name
     
  namespace-id = URI-symbol
  | user-ns-shortcut-symbol
     
  namespaces = (*NAMESPACES* namespace-assoc ...)
     
  namespace-assoc = (namespace-id uri-string maybe-original-prefix)
     
  annotations = (@ maybe-namespaces annotation ...)
     
  annotation = not yet specified

Refer to the original SXML specification for a more detailed explanation of the representation, including examples.

In short, an XML element is represented as a list consisting of its tag name as a symbol followed by its children nodes. If the XML element has attributes, they come immediately after the tag symbol, in a list tagged by an @ symbol.

For example, the XML element

<abc>def<ghi />jkl</abc>

is represented by the SXML datum

'(abc "def" (ghi) "jkl")

and the XML element

<customer specialness="gazonga">Barry White</customer>

is represented by the SXML datum

'(customer (@ (specialness "gazonga")) "Barry White")

That’s the easy part. Things get more icky when you start talking about documents and namespaces.