doc.txt

xxexpr.ss : Portable SXML to XML conversion

_xxexpr.ss_ : Portable SXML to XML conversion
=============================================

By Tony Garnock-Jones (tonyg at lshift dot net)
Documentation by Noel Welsh (noelwelsh at yahoo dot com)

Time-stamp: <05/11/13 21:26:48 noel>

Keywords: _xxexpr_ _sxml_ _xml_ _xexpr_


Introduction
============

The SSAX XML parsing- and processing-library provides
robust, high-quality XML reading tools for Scheme, but
doesn't include a general purpose XML writer. This library
provides functions to convert SXML-like data to an XML 1.0
external representation.

The library is parameterized over a choice of double- or
single-quotes for attribute printing, and can, if required,
be instructed to use explicit close-tags when an empty-tag
is encountered. It provides procedures for producing a
string representation of an XML fragment, for printing an
XML fragment directly to a port, and for pretty-printing an
XML fragment with indentation. For example,

  (pretty-print-xxexpr
    (let ((title "My Page"))
      (list
        '(*pi* xml (version "1.0"))
        `(html (head (title ,title))
           (body (h1 ,title)
                 (p "Hello, world!"))))))

produces the following output:

  <?xml version='1.0'?>
    <html>
      <head>
        <title>My Page</title>
      </head>
      <body>
        <h1>My Page</h1>
        <p>Hello, world!</p>
      </body>
    </html>

The code is portable and available for Chicken, SISC, and
MzScheme 209 in addition to this package.  The code can be
retrieved using darcs with the command

  darcs get http://www.lshift.net/~tonyg/xxexpr/

or browsed at

  http://www.lshift.net/~tonyg/xxexpr/


_Xxexpr.ss_
===========

To use this code:

  (require (planet "lshift" ("xxexpr.ss" "xxexpr.plt" 1 0)))

> xml-empty-tags-mode : Parameter containing #t or #f

This parameter determines if empty tags are rendered without
an explicit close tag, using the <tag/> shortcut syntax
(#t), or are rendered with an explicit close tag (#f).  The
default value is #t, meaning empty tags are rendered using
the shortcut syntax.

> xml-double-quotes-mode : Parameter containing #t or #f

This parameter determines whether double or single quotes
are used for delimiting attributes.  The default value is
#f., meaning attributes are delimited with single quotes.

> xxexpr->string : (list-of sxml) -> string

Converts  list of SXML fragments to a string.

> xxexpr->string/notags : (list-of xml) -> string

Converts a list of SXML fragments to a string, stripping
tags (that is, tags are not skipped).

> write-xxexpr : (list-of sxml) [output-port] -> #t

Writes the list of SXML fragments to the given output port,
or current-output-port if none is given.

> write-xxexpr/notags : (list-of sxml) [output-port] -> #t

Writes the list of SXML fragments, skipping tags, to the
given output port, or current-output-port if none is given.

> pretty-print-xxexpr : (list-of sxml) [output-port] -> #t

Pretty prints the list of SXML fragments to the given output
port, or current-output-port if none is given.


Examples
========

See the tests in xxexpr-test.ss