The SDOM Manual
***************

This manual describes the SDOM Scheme module.

   Copyright (C) 2007 Julian Graham.

     Permission is granted to copy, distribute and/or modify this
     document under the terms of the GNU Free Documentation License,
     Version 1.2 or any later version published by the Free Software
     Foundation; with no Invariant Sections, no Front-Cover Texts, and
     no Back-Cover Texts.  A copy of the license is included in the
     section entitled "GNU Free Documentation License".

   This reference manual documents SDOM, a Scheme module designed to be
a complete implementation of the W3C's Document Object Model
recommendation. It contains descriptions of the various aspects of the
SDOM API and explains some of SDOM's inner workings and how it can be
integrated with other Scheme modules.

   This Info file contains a development edition of the reference
manual, corresponding to the current development release of SDOM.

Appendices

Indices

1 Introduction
**************

SDOM aims to provide a complete Scheme implementation of the W3C's
Document Object Model API recommendation, as an extension of Oleg
Kiselyov's SXML project.  This document contains a description of the
SDOM API, including explanatory notes for cases in which the SDOM API
diverges significantly from the W3C recommendation.  In general, an
attempt has been made to replicate the recommendation's API
method-for-method, but because of inherent differences between rules
and conventions of the Scheme language and those of the languages for
which the DOM recommendation seems to have been initially intended, we
believe that some of the changes we made were requisite, if not
actually more desirable than the original. Some of the major
differences are discussed in the following sections.

2 Adherence to W3C DOM
**********************

2.1 Naming conventions
======================

The DOM recommendation assumes an object-oriented language similar in
syntax to C++ or Java, and, as such, follows the naming conventions of
those languages in the API it describes.  Given the obvious differences
between Scheme and, say, Java, the naming conventions favored by SDOM
are bit different.

   * All SDOM API members are prefixed by the string "sdom:" to prevent
     namespace clashes with other Scheme modules

   * The names of constants and enumeration members have been changed
     to lower-case

   * Internal capitalization within member names indicating word
     boundaries has been replaced with dashes.

   As a convenience to the reader, this manual includes, for each part
of the SDOM API that maps to a particular bit of the DOM API, the name
of the DOM API method or constant to which it corresponds.

2.2 Object orientation
======================

Probably the biggest difference.  The DOM recommendation presumes a
language such as C++ or Java that is capable of representing abstract
data types in a way that is not immediately compatible with standards
for data representation in Scheme.  Although, depending on one's choice
of Scheme compiler, various object-orientation frameworks may be
available, none seem to be portable across implementations; and, at any
rate, the grammar in SXML is, for the most part, sufficient for
distinguishing important types.

   As such, the Node interface and its descendants specified in the
Level 3 Core API are not present in SDOM.  Instead, SDOM attempts to
infer type according the rules presented in the section on Node Types.
Intermediate interfaces, such as CharacterData, from which the DOM node
types Text and CDATASection both inherit, have been omitted.  The
inheritance of node properties is still very much a feature of SDOM,
however, and is implemented transparently; for further discussion, see
the section on properties.

   Another consequence of the lack of object orientation in SDOM is
that many of the supporting data types in the DOM recommendation have
been omitted.  Some examples include:

   * DOMString

   * NamedNodeMap

3 Compatibility with SXML
*************************

One of the requirements in the implementation of SDOM was that it not
break with the grammar specified for parsed XML documents in the SXML
project.  In general, this  requirement was a straightforward one to
meet, but the variety of interfaces specified by the DOM recommendation
combined with the relative simplicity of SXML's grammar specification
necessitated the addition of a few special cases that will be addressed
shortly.

   The vast majority of the additional book-keeping required by SDOM is
implemented as a set of annotations that follow the guidelines set
forth by the SXML manual.

   As such, documents created by the SDOM API or created by the SXML
API and imported as SDOM documents are fully compatible with the SXML
API according to the following rules:

   * SXML selection operations can still be performed on any
     combination of CARs and CDRs of the *TOP* node of an SXML tree
     that has been annotated for use with the SDOM API

   * Operations that modify their input in place (such as set!)  should
     not be used on trees or subtrees generated by SDOM calls.  See the
     SDOM API reference for functions that will do the kinds of things
     you want (such as sdom:set-dom-property!)

   * The output of operations (such as transformation) that do not
     modify their input but return a newly-allocated result based on
     this input may need to be re-annotated with the sdom:sxml->sdom
     function before it can be used with SDOM API calls

   * The results of certain SDOM node selection operations
     (specifically ones that return nodes whose exterior
     representations are different from their interior representations)
     may not conform to the SXML grammar specification

4 Document parsing
******************

There are two ways that SDOM can translate an existing XML document
into a format in which it can be manipulated using SDOM's API: SDOM can
add the necessary book-keeping information to a document that has
already been parsed by SSAX; or it can read and parse the XML directly
from a Scheme input port, using a customized version of the SSAX
parser. This latter way is preferrable, since it preserves Document
Type Declarations and information about entities.

 -- Function: sdom:sxml->sdom sxml-doc
     Creates and returns a deep copy of the SXML tree SXML-DOC, adding
     to it the required book-keeping information and node annotations.

 -- Function: sdom:xml->sdom port namespace-decls
     Reads an XML document as a string from the input port PORT,
     parsing it into an SXML-compatible SDOM document.  If
     NAMESPACE-DECLS is non-null, it should be a list of

          PREFIX . NAMESPACE-URI

     ...where PREFIX is a symbol to be used as XML namespace shorthand
     for the string NAMESPACE-URI, and will be used to resolve
     namespace prefixes encountered during parsing. If the available
     SSAX implementation exports the MAKE-PARSER macro, a customized
     version the SSAX parser that preserves DTD and entity information
     will be used; otherwise the behavior will be identical to that of
     SDOM:SXML->SDOM.

5 Implementation details
************************

5.1 Interior and exterior node representations
==============================================

As mentioned above, one of the challenges in implementing a DOM on top
of SXML was that SXML's grammar does not directly directly provide the
means for handling the range of types specified by the DOM
recommendation.  For example, without a number of contextual clues, it
is difficult or impossible to distinguish between an attribute and an
element or between a text node or a CDATA section, as presented in an
SXML document.  As a solution to this problem, SDOM represents
"ambiguous" nodes in two different ways:

   - As an "interior" node whose parent contains descriptive
annotations based on the position of the node.  For example,   the node
expression:

     (foo (@ (@ (@-1 ((sdom:is-cdata #t)))
          "bar" (*COMMENT* "baz"))

   represents an element node with two children - a CDATA   section
that contains the string "foo" and a comment with   text "baz."  The
annotation 1 on foo is actually an   annotation for its first child -
SXML does not permit   annotations for CDATA sections.

   - As an "exterior" node, a form in which the requisite   annotations
are attached to the node itself, but which may not   actually be
grammatically correct as SXML.  For example, the   node expression:

     ("bar" (@ (sdom:is-cdata #t)
               (sdom:sxml-representation "bar")))

   represents the same CDATA section in the example above, but
outside the context of its parent.  The annotations attached   to it
are the same ones as when it is in interior context,   with the
addition of the "sxml-representation" property,   which provides a
reference to the object as it appears in its   interior context (i.e.,
an object that can be located as a   child of the parent using the eq?
predicate).  Any   modification operations (properly) applied to the
exterior   representation of a node will cause the interior
representation to be updated correctly as well.

5.2 Namespace management
========================

The default behavior of the SXML ssax:xml->sxml parser with regard to
XML namespaces is to resolve any prefixes it finds to their
corresponding namespace URIs (provided these are specified by the
document) and then replace all prefixes with either a symbolic form of
the URI or a so-called "user namespace shortcut," depending on whether
or not a list of shortcuts is specified at parse time.  The original
prefix is not made available as part of the namespace mapping in the
resulting S-list.

   Because this behavior is the default for SXML (it can be changed,
but doing so is not straightforward) and because DOM does not
explicitly discuss the use of such shortcuts, SDOM treats them as being
interchangeable with coventional XML namespace prefixes.  This behavior
can be modified on a per-document basis with a call to
sdom:set-dom-configuration-parameter!, setting the option
"sdom:prefer-orig-prefix" to "true."  If this option is set, SDOM
functions that manipulate prefixes will look for the original prefix in
the namespace declaration before looking at the user namespace shortcut.

   For example, a typical namespace declaration in an SXML document
looks like this:

     (*NAMESPACES* (foo "http://www.foo.bar.com/"))

   provided you've invoked ssax:xml->sxml something like this:

     (ssax:xml->sxml (open-input-file "baz.xml")
                     '((foo "http://www.foo.bar.com/"))))

   where baz.xml contains:

     <?xml version="1.0"?>
     <doc xmlns:baz="http://www.foo.bar.com/">
       <baz:element/>
     </doc>

   (If you don't provide the mapping of shortcuts to URIs, you won't,
by default, get any namespace declarations, and all prefixes will be
translated to symbolized URIs - baz:element will become
http://www.foo.bar.com:element.)  So, by default, if you evaluate
sdom:lookup-prefix for "foo" on the appropriate node, you'll get
"http://www.foo.bar.com/," even though foo may not actually have been a
prefix.  Likewise, a call to sdom:lookup-namespace-uri on
"http://www.foo.bar.com/" will return foo.

   Now let's say you've constructed your SXML parser so that it
preserves prefixes and stores them in namespace declarations, which now
look more like this:

     (*NAMESPACES* (foo "http://www.foo.bar.com/" baz))

   If you've set sdom:prefer-orig-prefix to true, then a call to
sdom:lookup-prefix for both foo and baz will return
"http://www.foo.bar.com/."  A call to sdom:lookup-namespace-uri on
"http://www.foo.bar.com/" will return baz.  (If the original prefix is
not available, sdom:lookup-namespace-uri will return foo instead.)

6 Event handling
****************

6.1 Event API
=============

6.2 Event property reference
============================

6.2.1 Properties for Events
---------------------------

 -- Variable: sdom:type
 -- Variable: Event.type

 -- Variable: sdom:target
 -- Variable: Event.target

 -- Variable: sdom:current-target
 -- Variable: Event.currentTarget

 -- Variable: sdom:event-phase
 -- Variable: Event.eventPhase

 -- Variable: sdom:bubbles
 -- Variable: Event.bubbles

 -- Variable: sdom:cancelable
 -- Variable: Event.cancelable

 -- Variable: sdom:time-stamp
 -- Variable: Event.timeStamp

 -- Variable: sdom:namespace-uri
 -- Variable: Event.namespaceURI

6.2.1.1 Properties for Custom Events
....................................

6.2.1.2 Properties for UI Events
................................

 -- Variable: sdom:view
 -- Variable: UIEvent.view

 -- Variable: sdom:detail
 -- Variable: UIEvent.detail

6.2.1.3 Properties for Mutation Events
......................................

 -- Variable: sdom:related-node
 -- Variable: MutationEvent.relatedNode

 -- Variable: sdom:prev-value
 -- Variable: MutationEvent.prevValue

 -- Variable: sdom:new-value
 -- Variable: MutationEvent.newValue

 -- Variable: sdom:attr-name
 -- Variable: MutationEvent.attrName

 -- Variable: sdom:attr-change
 -- Variable: MutationEvent.attrChange

7 Type reference
****************

7.1 Node types
==============

These are the constants that will be returned by a request to resolve
the type of node. They can also be used in calls to sdom:create-node.
Since the DOM recommendation appears to consider these mappings to be
invariant (though not exhaustive) it is probably safe to use the
numerical values in your code; the symbols are provided for your
convenience.

 -- Variable: sdom:node-type-element
 -- Variable: ELEMENT_NODE
     (constant value = 1)

 -- Variable: sdom:node-type-attr
 -- Variable: ATTRIBUTE_NODE
     (constant value = 2)

 -- Variable: sdom:node-type-text
 -- Variable: TEXT_NODE
     (constant value = 3)

 -- Variable: sdom:node-type-cdata-section
 -- Variable: CDATA_SECTION_NODE
     (constant value = 4)

 -- Variable: sdom:node-type-entity-reference
 -- Variable: ENTITY_REFERENCE_NODE
     (constant value = 5)

 -- Variable: sdom:node-type-entity
 -- Variable: ENTITY_NODE
     (constant value = 6)

 -- Variable: sdom:node-type-processing-instruction
 -- Variable: PROCESSING_INSTRUCTION_NODE
     (constant value = 7)

 -- Variable: sdom:node-type-comment
 -- Variable: COMMENT_NODE
     (constant value = 8)

 -- Variable: sdom:node-type-document
 -- Variable: DOCUMENT_NODE
     (constant value = 9)

 -- Variable: sdom:node-type-document-type
 -- Variable: DOCUMENT_TYPE_NODE
     (constant value = 10)

 -- Variable: sdom:node-type-document-fragment
 -- Variable: DOCUMENT_FRAGMENT_NODE
     (constant value = 11)

 -- Variable: sdom:node-type-notation
 -- Variable: NOTATION_NODE
     (constant value = 12)

7.2 Event types
===============

 -- Variable: sdom:event-load
 -- Variable: load

 -- Variable: sdom:event-unload
 -- Variable: unload

 -- Variable: sdom:event-abort
 -- Variable: abort

 -- Variable: sdom:event-error
 -- Variable: error

 -- Variable: sdom:event-select
 -- Variable: select

 -- Variable: sdom:event-change
 -- Variable: change

 -- Variable: sdom:event-submit
 -- Variable: submit

 -- Variable: sdom:event-reset
 -- Variable: reset

 -- Variable: sdom:event-resize
 -- Variable: resize

 -- Variable: sdom:event-scroll
 -- Variable: scroll

 -- Variable: sdom:event-dom-activate
 -- Variable: DOMActivate

 -- Variable: sdom:event-dom-focus-in
 -- Variable: DOMFocusIn

 -- Variable: sdom:event-dom-focus-out
 -- Variable: DOMFocusOut

 -- Variable: sdom:event-text-input
 -- Variable: textInput

 -- Variable: sdom:event-click
 -- Variable: click

 -- Variable: sdom:event-mousedown
 -- Variable: mousedown

 -- Variable: sdom:event-mouseup
 -- Variable: mouseup

 -- Variable: sdom:event-mouseover
 -- Variable: mouseover

 -- Variable: sdom:event-mousemove
 -- Variable: mousemove

 -- Variable: sdom:event-mouseout
 -- Variable: mouseout

 -- Variable: sdom:event-keydown
 -- Variable: keydown

 -- Variable: sdom:event-keyup
 -- Variable: keyup

 -- Variable: sdom:event-dom-subtree-modified
 -- Variable: DOMSubtreeModified

 -- Variable: sdom:event-dom-node-inserted
 -- Variable: DOMNodeInserted

 -- Variable: sdom:event-dom-node-removed
 -- Variable: DOMNodeRemoved

 -- Variable: sdom:event-dom-node-removed-from-document
 -- Variable: DOMNodeRemovedFromDocument

 -- Variable: sdom:event-dom-node-inserted-into-document
 -- Variable: DOMNodeInsertedIntoDocument

 -- Variable: sdom:event-dom-element-name-changed
 -- Variable: DOMElementNameChanged

 -- Variable: sdom:event-dom-attribute-name-changed
 -- Variable: DOMAttrNameChanged

7.3 Exception types
===================

 -- Variable: sdom:exception-code-index-size-err
 -- Variable: INDEX_SIZE_ERR
     (constant value = 1)

 -- Variable: sdom:exception-code-domstring-size-err
 -- Variable: DOMSTRING_SIZE_ERR
     (constant value = 2)

 -- Variable: sdom:exception-code-hierarchy-request-err
 -- Variable: HIERARCHY_REQUEST_ERR
     (constant value = 3)

 -- Variable: sdom:exception-code-wrong-document-err
 -- Variable: WRONG_DOCUMENT_ERR
     (constant value = 4)

 -- Variable: sdom:exception-code-invalid-character-err
 -- Variable: INVALID_CHARACTER_ERR
     (constant value = 5)

 -- Variable: sdom:exception-code-no-data-allowed-err
 -- Variable: NO_DATA_ALLOWED_ERR
     (constant value = 6)

 -- Variable: sdom:exception-code-no-modification-allowed-err
 -- Variable: NO_MODIFICATION_ALLOWED_ERR
     (constant value = 7)

 -- Variable: sdom:exception-code-not-found-err
 -- Variable: NOT_FOUND_ERR
     (constant value = 8)

 -- Variable: sdom:exception-code-not-supported-err
 -- Variable: NOT_SUPPORTED_ERR
     (constant value = 9)

 -- Variable: sdom:exception-code-inuse-attribute-err
 -- Variable: INUSE_ATTRIBUTE_ERR
     (constant value = 10)

 -- Variable: sdom:exception-code-invalid-state-err
 -- Variable: INVALID_STATE_ERR
     (constant value = 11)

 -- Variable: sdom:exception-code-syntax-err
 -- Variable: SYNTAX_ERR
     (constant value = 12)

 -- Variable: sdom:exception-code-invalid-modification-err
 -- Variable: INVALID_MODIFICATION_ERR
     (constant value = 13)

 -- Variable: sdom:exception-code-namespace-err
 -- Variable: NAMESPACE_ERR
     (constant value = 14)

 -- Variable: sdom:exception-code-invalid-access-err
 -- Variable: INVALID_ACCESS_ERR
     (constant value = 15)

 -- Variable: sdom:exception-code-validation-err
 -- Variable: VALIDATION_ERR
     (constant value = 16)

 -- Variable: sdom:exception-code-type-mismatch-err
 -- Variable: TYPE_MISMATCH_ERR
     (constant value = 17)

7.4 User data event types
=========================

 -- Variable: sdom:user-data-event-node-cloned
 -- Variable: NODE_CLONED
     (constant value = 1)

 -- Variable: sdom:user-data-event-node-imported
 -- Variable: NODE_IMPORTED
     (constant value = 2)

 -- Variable: sdom:user-data-event-node-deleted
 -- Variable: NODE_DELETED
     (constant value = 3)

 -- Variable: sdom:user-data-event-node-renamed
 -- Variable: NODE_RENAMED
     (constant value = 4)

 -- Variable: sdom:user-data-event-node-adopted
 -- Variable: NODE_ADOPTED
     (constant value = 5)

7.5 SDOM constants
==================

8 SDOM API reference
********************

The following functions are described in terms of their respective
counterparts in the W3C DOM recommendation; you should refer to that
document for more thorough discussion of the expected behavior.

   On the other hand, this implementation does not adhere strictly to
the organization of interfaces in the recommendation, so the following
groupings are based on the purpose of the functions they contain, not
on their position within the DOM hierarchy.

8.1 Node creation
=================

 -- Function: sdom:create-document rootname dtd rootns
 -- Function: DOMImplementation.createNode
     Returns a new document node with document type given by DTD and
     document element with QName ROOTNAME and namespace ROOTNS. DTD may
     be null if no document type is required; if ROOTNAME is null, the
     resulting document will have no document element.

 -- Function: sdom:create-document-type qname public-id system-id

 -- Function: sdom:create-node document node-type args...
     Creates and returns a new node of type NODE-TYPE, whose
     owner-document is DOCUMENT. This function can be used to create
     all non-Document node types, according to the following table,
     which gives the significance and required types of the optional
     arguments according to NODE-TYPE.

     Node type                   Arg1                 Arg2
     ----------------------------------------------------------------------
     sdom:node-type-element      qname, as string     [namespace, as
                                                      string]
     sdom:node-type-attr         qname, as string     [namespace, as
                                                      string]
     sdom:node-type-text         content, as string
     sdom:node-type-cdata-sectioncontent, as string
     sdom:node-type-entity-referenceentity name, as
                                 string
     sdom:node-type-entity
     sdom:node-type-processing-instructiontarget, as string    data, as string
     sdom:node-type-comment      value, as string
     sdom:node-type-document-type
     sdom:node-type-document-fragment
     sdom:node-type-notation

     For example, to create a new Element node, you could use either of
     the following expressions:

          (sdom:create-node doc sdom:node-type-element "xhtml:p"
                            "http://www.w3.org/1999/xhtml")
          (sdom:create-node doc sdom:node-type-element "p")

8.2 Node manipulation
=====================

 -- Function: sdom:insert-before! parent new-node [ref-node]
 -- Function: Node.insertBefore
     Inserts NEW-NODE as a new child node of PARENT.  If REF-NODE is
     specified, this function will insert NEW-NODE such that it
     precedes REF-NODE as a child of PARENT in the document order;
     otherwise its behavior will be identical to that of
     SDOM:APPEND-CHILD!.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-WRONG-DOCUMENT-ERR if NEW-NODE and
          PARENT do not belong to the same document

        * Throws SDOM:EXCEPTION-CODE-HIERARCHY-REQUEST-ERR if nodes of
          NEW-NODE's type cannot be children of PARENT

        * Throws SDOM:EXCEPTION-CODE-NOT-FOUND-ERR if REF-NODE is not a
          child of PARENT

     Events:
        * SDOM:EVENT-DOM-NODE-INSERTED will be dispatched if the
          insertion completes successfully

 -- Function: sdom:insert-after! parent new-node [ref-node]
 -- Function: Node.insertAfter
     Inserts NEW-NODE as a new child node of PARENT.  If REF-NODE is
     specified, this function will insert NEW-NODE such that it follows
     REF-NODE as a child of PARENT in the document order; otherwise its
     behavior will be identical to that of SDOM:APPEND-CHILD!.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-WRONG-DOCUMENT-ERR if NEW-NODE and
          PARENT do not belong to the same document

        * Throws SDOM:EXCEPTION-CODE-HIERARCHY-REQUEST-ERR if nodes of
          NEW-NODE's type cannot be children of PARENT

        * Throws SDOM:EXCEPTION-CODE-NOT-FOUND-ERR if REF-NODE is not a
          child of PARENT

     Events:
        * SDOM:EVENT-DOM-NODE-INSERTED will be dispatched if the
          insertion completes successfully

 -- Function: sdom:append-child! parent node
 -- Function: Node.appendChild
     Appends NODE as a new child of PARENT, returning NODE. If NODE has
     a non-null parent, it is first removed.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-WRONG-DOCUMENT-ERR if NODE and
          PARENT do not belong to the same document

        * Throws SDOM:EXCEPTION-CODE-HIERARCHY-REQUEST-ERR if nodes of
          NODE's type cannot be children of PARENT

 -- Function: sdom:remove-child! parent node
 -- Function: Node.removeChild

 -- Function: sdom:replace-child! parent new-child old-child
 -- Function: Node.replaceChild
     Throws SDOM:EXCEPTION-CODE-NOT-FOUND-ERR if OLD-CHILD is not a
     child of PARENT

 -- Function: sdom:clone-node node deep
 -- Function: Node.clone

 -- Function: sdom:adopt-node! document node
 -- Function: Document.adoptNode
     Destructively adopts NODE into DOCUMENT.  NODE is removed as a
     child of any parent it may have; the SDOM:OWNER-DOCUMENT property
     for NODE is set to DOCUMENT.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-NOT-SUPPORTED-ERR if NODE cannot
          be adopted because it has type SDOM:NODE-TYPE-DOCUMENT or
          SDOM:NODE-TYPE-DOCUMENT-TYPE

        * Throws SDOM:EXCEPTION-CODE-NO-MODIFICATION-ALLOWED-ERR if
          NODE is readonly

 -- Function: sdom:import-node document node deep
 -- Function: Document.importNode

8.3 Node predicates
===================

 -- Function: sdom:same-node? node1 node2
 -- Function: Node.isSameNode
     Returns #T if NODE1 and NODE2 are the same, according to the rules
     set forth in the W3C recommendation for node sameness, #F
     otherwise. In general in SDOM, two nodes are the same if they are
     equal under the eq? predicate or have internal representations
     that are the same under the eq?  predicate.

 -- Function: sdom:equal-node? node1 node2
 -- Function: Node.equalNode
     Returns #T if NODE1 and NODE2 are equal, according to the rules
     set forth in the W3C recommendation for node equality, #F
     otherwise.

 -- Function: sdom:has-child-nodes? node
 -- Function: Node.hasChildNodes
     Returns #T if NODE has child nodes, #F otherwise.

 -- Function: sdom:supported? node feature version
 -- Function: Node.isSupported

 -- Function: sdom:compare-document-position node1 node2
 -- Function: Node.compareDocumentPosition

8.4 Properties and configuration
================================

 -- Function: sdom:set-dom-property! node property value
     Errors:
        * Throws SDOM:EXCEPTION-CODE-NOT-FOUND-ERR if PROPERTY is not a
          property of NODE or any of its inherited interfaces

        * Throws SDOM:EXCEPTION-CODE-NO-MODIFICATION-ALLOWED-ERR if
          PROPERTY is a read-only property of NODE

        * This procedure will also throw any errors generated while
          carrying out the operations required to set the specified
          property.  See the property documentation for a list of
          potential errors

 -- Function: sdom:get-dom-property node property
     Errors:
        * Throws SDOM:EXCEPTION-CODE-NOT-FOUND-ERR if PROPERTY is not a
          property of NODE or any of its inherited interfaces

8.4.1 DOM Configuration Parameters
----------------------------------

DOM configuration parameters control the behavior of a DOM
implementation for a particular document during document normalization.
They can be retrieved and set for a particular document, but SDOM does
not consider them to be DOM properties that are stored in the document
tree itself; rather, they are considered to be "out-of-band" data and
are maintained in a separate hash table that is keyed on document
nodes. This means they will not be available across loads and saves of
the document to which they are attached.

   SDOM implements the following DOM configuration parameters, which
can be modified for a particular document using the functions described
below (see the DOM recommendation for information on their meaning
during normalization):

Name                                 Supported values   Default
---------------------------------------------------------------------------
"canonical-form"                     #F                 #F
"cdata-sections"                     #T #F              #T
"check-character-normalization"      #F                 #F
"comments"                           #T #F              #T
"datatype-normalization"             #F                 #F
"element-content-whitespace"         #T                 #T
"entities"                           #T #F              #T
"error-handler"                      DEFAULT_HANDLER    HANDLER_PROCEDURE
"infoset"                            #F #F              #T
"namespaces"                         #T                 #T
"namespace-declarations"             #F #T              #T
"normalize-characters"               #F                 #F
"split-cdata-sections"               #T #F              #T
"strict-error-checking"              #T #F              #T
"validate"                           #F                 #F
"validate-if-schema"                 #F                 #F
"well-formed"                        #T                 #T
"sdom:prefer-orig-prefix"            #F #F              #T
"sdom:resolve-new-prefixes"          #T #F              #T

 -- Function: sdom:get-dom-config-parameter document param
 -- Function: DOMConfiguration.getParameter
     Return the value of the configuration parameter PARAM for the
     document DOCUMENT.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if DOCUMENT is
          not a document node

 -- Function: sdom:set-dom-config-parameter! document param value
 -- Function: DOMConfiguration.setParameter
     Sets the value of the configuration parameter PARAM for the
     document DOCUMENT to VALUE.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if DOCUMENT is
          not a document node

        * Throws SDOM:EXCEPTION-CODE-NOT-FOUND-ERR if PARAM is not a
          valid DOM configuration parameter

        * Throws SDOM:EXCEPTION-CODE-NOT-SUPPORT-ERR if VALUE is not a
          valid value for the DOM configuration parameter PARAM

 -- Function: sdom:can-set-dom-config-parameter? document param value
 -- Function: DOMConfiguration.canSetParameter
     Returns #F if a call to SDOM:SET-DOM-CONFIG-PARAMETER! for
     document DOCUMENT and arguments PARAM and VALUE would lead to an
     exception being thrown, #T otherwise.

8.5 Namespaces
==============

8.6 Functions on Documents
==========================

 -- Function: sdom:normalize-document! document
 -- Function: Document.normalizeDocument
     Puts DOCUMENT into "normal" form, potentially destructively
     modifying the structure of DOCUMENT, depending on which DOM
     configuration parameters are in place for this document

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if DOCUMENT is
          not of type SDOM:NODE-TYPE-DOCUMENT

        * Selected DOM Errors will be raised, depending on the DOM
          configuration parameters attached to DOCUMENT

 -- Function: sdom:get-element-by-id document value
 -- Function: Document.getElementById
     Returns the first element found in a document order traversal of
     the document DOCUMENT that has an attribute identified as an id
     attribute whose value is VALUE.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if DOCUMENT is
          not of type SDOM:NODE-TYPE-DOCUMENT

 -- Function: sdom:get-elements-by-tag-name document name [namespace]
 -- Function: Document.getElementsByTagName
     Returns a list of element nodes in the document given by DOCUMENT
     for which the DOM property "sdom:tag-name" is equal to the string
     NAME. If NAMESPACE is given, the nodes must also belong to a
     namespace whose URI is equal to NAMESPACE.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if DOCUMENT is
          not of type SDOM:NODE-TYPE-DOCUMENT

8.7 Functions on Elements
=========================

 -- Function: sdom:get-attribute-node element name [namespace]
 -- Function: Element.getAttributeNode
     Returns the attr node attached to ELEMENT whose is name is NAME
     and whose namespace is NAMESPACE, if specified.  If no such attr
     node exists, returns null.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if ELEMENT is
          not of type SDOM:NODE-TYPE-ELEMENT

 -- Function: sdom:set-attribute-node! element attr
 -- Function: Element.setAttributeNode
     Attaches the attr node ATTR as a new attribute of element ELEMENT.
     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if ELEMENT is
          not of type SDOM:NODE-TYPE-ELEMENT or ATTR is not of type
          SDOM:NODE-TYPE-ATTR Throws
          SDOM:EXCEPTION-CODE-WRONG-DOCUMENT-ERR if ELEMENT and ATTR do
          not belong to the same document Throws
          SDOM:EXCEPTION-CODE-INUSE-ATTRIBUTE-ERR if the
          "sdom:owner-element" property for ATTR is not null

 -- Function: sdom:remove-attribute-node! element attr
 -- Function: Element.removeAttributeNode
     Removes the attr node ATTR from its owner element, ELEMENT.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if ELEMENT is
          not of type SDOM:NODE-TYPE-ELEMENT or ATTR is not of type
          SDOM:NODE-TYPE-ATTR Throws
          SDOM:EXCEPTION-CODE-WRONG-DOCUMENT-ERR if ELEMENT and ATTR do
          not belong to the same document Throws
          SDOM:EXCEPTION-CODE-NOT-FOUND-ERR if ATTR is not already
          attached to ELEMENT

 -- Function: sdom:get-attribute element name [namespace]
 -- Function: Element.getAttribute
     Returns the value of the attribute attached to ELEMENT whose is
     name is NAME and whose namespace is NAMESPACE, if specified. If no
     such attribute exists, returns null.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if ELEMENT is
          not of type SDOM:NODE-TYPE-ELEMENT

 -- Function: sdom:set-attribute! element name value [namespace]
 -- Function: Element.setAttribute
     Sets VALUE as the value for the attribute attached to element
     ELEMENT whose name is NAME and whose namespace is NAMESPACE, if
     specified.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if ELEMENT is
          not of type SDOM:NODE-TYPE-ELEMENT

 -- Function: sdom:remove-attribute! element name [namespace]
 -- Function: Element.removeAttribute
     Removes the attribute from element ELEMENT whose name is NAME and
     whose namespace is NAMESPACE, if specified.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if ELEMENT is
          not of type SDOM:NODE-TYPE-ELEMENT

 -- Function: sdom:set-id-attribute! element name is-id [namespace]
 -- Function: Element.setIdAttribute
     Attaches an annotation to the attribute attached to element
     ELEMENT whose name is NAME and whose namespace is NAMESPACE, if
     specified, that indicates, based on the boolean value IS-ID,
     whether or not the attribute should be used as an id attribute.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if ELEMENT is
          not of type SDOM:NODE-TYPE-ELEMENT

 -- Function: sdom:set-id-attribute-node! element attr is-id
 -- Function: Element.setIdAttributeNode
     Attaches an annotation to the attr node ATTR attached to element
     ELEMENT that indicates, based on the boolean value IS-ID, whether
     or not the attribute should be used as an id attribute.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if ELEMENT is
          not of type SDOM:NODE-TYPE-ELEMENT or ATTR is not of type
          SDOM:NODE-TYPE-ATTR Throws SDOM:EXCEPTION-CODE-NOT-FOUND-ERR
          if ATTR is not attached to ELEMENT

8.8 Functions on Text nodes
===========================

 -- Function: sdom:replace-whole-text! node text
 -- Function: Text.replaceWholeText
     Replaces the text content of NODE and all adjacent text nodes
     (according to document order) with the string TEXT.  If adjacent
     text nodes exist, they will be removed.

     Errors:
        * Throws SDOM:EXCEPTION-CODE-TYPE-MISMATCH-ERR if NODE is not
          of type SDOM:NODE-TYPE-TEXT

8.9 User data
=============

The SDOM user data API allows programmers to attach arbitrary data to
particular nodes using a hashtable-like mechanism, and to register
handler procedures that will be called when the node is affected by a
particular node manipulation function.

   Like DOM configuration parameters, SDOM does not consider user data
to be a persistent part of an XML document; as such, user data and
handlers are stored in a hashtable separate from the document itself
and will not be available outside the current process space.

 -- Function: sdom:get-user-data node key
 -- Function: Node.getUserData
     Retrieves the user data stored for NODE under the key string KEY,
     or null if none exists.

 -- Function: sdom:set-user-data! node key value handler
 -- Function: Node.setUserData
     Stores the value VALUE and a handler procedure HANDLER under the
     key string KEY for node NODE. The handler should have the
     following signature:

          (lambda (op key value src dst) ...)

     It will be called such that OP is one of the user data event types
     defined in the enumeration here; KEY is the key string that was
     used in the original call that installed the handler; VALUE is the
     value used in the call; SRC and DST are references to,
     respectively, the source and destination nodes involved in the
     event. For some events, DST may be null.

     If no handler is desired, pass null in place of a procedure.

9 SDOM property reference
*************************

9.1 Properties for Nodes
========================

The following properties apply to all node types, since, under the DOM
recommendation they all share the same root interface.

 -- Variable: sdom:node-type
 -- Variable: Node.nodeType
     The type of NODE.  See Node types.

     This property is read-only

 -- Variable: sdom:node-name
 -- Variable: Node.nodeName
     The name of NODE.  This value depends on the type of NODE.  If
     NODE has type SDOM:NODE-TYPE-ELEMENT or SDOM:NODE-TYPE-ATTR this
     value will be a symbol; otherwise it will be a string or NULL.  See
     `http://www.w3c.org/TR/2004/REC-DOM-Level-3-Core-20040407/' for
     more information.

     This property is read-only

 -- Variable: sdom:node-value
 -- Variable: Node.nodeValue
     The value of NODE.  This value depends on the type of NODE.  If
     the DOM recommendation defines this value to be null, setting it
     will have no effect.

     Errors on setting:
        * Throws SDOM:EXCEPTION-CODE-NO-MODIFICATION-ALLOWED-ERR if
          node is read-only and the DOM recommendation does not define
          it to be null

 -- Variable: sdom:parent-node
 -- Variable: Node.parentNode
     Property type: Node

     The parent of NODE, if it is defined to have one and is a member
     of a document tree; #F otherwise

     This property is read-only

 -- Variable: sdom:child-nodes
 -- Variable: Node.childNodes
     Property type: List of nodes

     A list of the child nodes of NODE, if it has any; NULL if there
     are no children or if NODE is not defined to have any

     This property is read-only

 -- Variable: sdom:first-child
 -- Variable: Node.firstChild
     Property type: Node

     The first item in the list of children of NODE, if there are any
     children, #F otherwise.  The value of this property is equivalent
     to the CAR of the value of SDOM:CHILD-NODES

     This property is read-only

 -- Variable: sdom:last-child
 -- Variable: Node.lastChild
     Property type: Node

     The last item in the list of children of NODE, if there are any
     children, #F otherwise.  The value of this property is equivalent
     to the CAR of the last pair of the value of SDOM:CHILD-NODES

     This property is read-only

 -- Variable: sdom:previous-sibling
 -- Variable: Node.previousSibling
     Property type: Node

     The item that precedes NODE in the parent's list of child nodes,
     or #F if there is no parent node or NODE is the first child of the
     parent

     This property is read-only

 -- Variable: sdom:next-sibling
 -- Variable: Node.nextSibling
     Property type: Node

     The item that follows NODE in the parent's list of child nodes, or
     #F if there is no parent node or NODE is the last child of the
     parent

     This property is read-only

 -- Variable: sdom:attributes
 -- Variable: Node.attributes
     Property type: List of nodes

     A list of the attributes attached to NODE; NULL if NODE is not of
     type SDOM:NODE-TYPE-ELEMENT or it has no attributes

     This property is read-only

 -- Variable: sdom:owner-document
 -- Variable: Node.ownerDocument
     Property type: Node

     The document node representing the document to which NODE belongs,
     or #F if the document cannot be determined or if NODE is itself of
     type SDOM:NODE-TYPE-DOCUMENT

     This property is read-only

 -- Variable: sdom:namespace-uri
 -- Variable: Node.namespaceURI
     Property type: String

     The namespace URI attached to NODE at the time of its creation or
     #F if none was specified.

     This property is read-only

 -- Variable: sdom:prefix
 -- Variable: Node.prefix
     The namespace prefix for NODE, or #F if it is unspecified. This
     property can only be set for element and attr nodes; setting it on
     any other type of node will have no effect.

     Errors on setting:
        * Throws SDOM:EXCEPTION-CODE-INVALID-CHARACTER-ERR if new value
          contains character that is illegal in the XML version
          specified by SDOM:XML-VERSION property of node's owner
          document

        * Throws SDOM:EXCEPTION-CODE-NO-MODIFICATION-ALLOWED-ERR if
          node is read-only

        * Throws SDOM:EXCEPTION-CODE-NAMESPACE-ERR if new value is not
          a well-formed prefix, or new value is "xml" and
          SDOM:NAMESPACE-URI property of node is not
          "http://www.w3.org/XML/1998/namespace", or node has type
          SDOM:NODE-TYPE-ATTR and new value is "xmlns" and
          SDOM:NAMESPACE-URI property of node is not
          "http://www.w3.org/2000/xmlns/", or node has type
          SDOM:NODE-TYPE-ATTR and SDOM:QUALIFIED-NAME property of node
          is "xmlns"

 -- Variable: sdom:local-name
 -- Variable: Node.localName
     Property type: String

     The local part of the qualified name for NODE, or #F if NODE is
     not an element or attr node.

     This property is read-only

 -- Variable: sdom:base-uri
 -- Variable: Node.baseURI
     Property type: String

     The base URI of NODE, as determined by the algorithms described in
     the W3C Recommendation, or #F if a value could not be determined.

     This property is read-only

 -- Variable: sdom:text-content
 -- Variable: Node.textContent
     Errors on setting:
        * Throws SDOM:EXCEPTION-CODE-NO-MODIFICATION-ALLOWED-ERR if
          node is read-only

9.1.1 Properties for Character Data nodes
-----------------------------------------

 -- Variable: sdom:data
 -- Variable: CharacterData.data
     Property type: String

     The content of NODE, represented as a string of UTF-16 characters

     Errors on setting:
        * Throws SDOM:EXCEPTION-CODE-NO-MODIFICATION-ALLOWED-ERR if
          node is read-only

 -- Variable: sdom:length
 -- Variable: CharacterData.length
     Property type: Number

     The length of the value of the SDOM:DATA property of NODE in
     UTF-16 characters

     This property is read-only

9.1.1.1 Properties for Text nodes
.................................

 -- Variable: sdom:is-element-content-whitespace
 -- Variable: Text.isElementContentWhitespace
     Property type: Boolean

     #T if the content of NODE represents the whitespace between
     elements introduced by user formatting, as determined during
     normalization of the document to which NODE belongs(1); #F
     otherwise

     This property is read-only

 -- Variable: sdom:whole-text
 -- Variable: Text.wholeText
     Property type: String

     A concatenation of all nodes of type SDOM:NODE-TYPE-TEXT or
     SDOM:NODE-TYPE-CDATA-SECTION, adjacent to NODE in a document order
     traversal that does not cross any nodes of type
     SDOM:NODE-TYPE-ELEMENT, SDOM:NODE-TYPE-COMMENT or
     SDOM:NODE-TYPE-PROCESSING-INSTRUCTION

     This property is read-only

   ---------- Footnotes ----------

   (1) The DOM recommendation specifies that this determination can
also be made at load time, but since SDOM relies on SSAX for parsing
documents, this information is not reliably available.

9.1.2 Properties for Notation nodes
-----------------------------------

 -- Variable: sdom:public-id
 -- Variable: Notation.publicId
     Property type: String

     The public identifier for NODE or #F if none was specified

     This property is read-only

 -- Variable: sdom:system-id
 -- Variable: Notation.systemId
     Property type: String

     The system identifier for NODE or #F if none was specified

     This property is read-only

9.1.3 Properties for Entities
-----------------------------

 -- Variable: sdom:public-id
 -- Variable: Entity.publicId
     Property type: String

     The public identifier for NODE or #F if none was specified

     This property is read-only

 -- Variable: sdom:system-id
 -- Variable: Entity.systemId
     Property type: String

     The system identifier for NODE or #F if none was specified

     This property is read-only

 -- Variable: sdom:notation-name
 -- Variable: Entity.notationName
     Property type: String

     The name of the notation for NODE if NODE is an unparsed entity,
     #F otherwise

     This property is read-only

 -- Variable: sdom:input-encoding
 -- Variable: Entity.inputEncoding
     Property type: String

     The name of the encoding for NODE at parse time, if NODE is an
     external parsed entity; #F otherwise

     This property is read-only

 -- Variable: sdom:xml-encoding
 -- Variable: Entity.xmlEncoding
     Property type: String

     The name of the encoding for NODE, if NODE is an external parsed
     entity; #F otherwise

     This property is read-only

 -- Variable: sdom:xml-version
 -- Variable: Entity.xmlVersion
     Property type: String

     The version number for NODE, if NODE is an external parsed entity;
     #F otherwise

     This property is read-only

9.1.4 Properties for Processing Instruction nods
------------------------------------------------

 -- Variable: sdom:target
 -- Variable: ProcessingInstruction.target
     Property type: String

     The target of NODE

     This property is read-only

 -- Variable: sdom:data
 -- Variable: ProcessingInstruction.data
     Property type: String

     The content of NODE

     Errors on setting:
        * Throws SDOM:EXCEPTION-CODE-NO-MODIFICATION-ALLOWED-ERR if
          node is read-only

9.1.5 Properties for Attr nodes
-------------------------------

 -- Variable: sdom:name
 -- Variable: Attr.name
     Property type: String

     The name of NODE. This will be a qualified name if SDOM:LOCAL-NAME
     is not #F

     This property is read-only

 -- Variable: sdom:specified
 -- Variable: Attr.specified
     Property type: Boolean

     Whether or not NODE has been given a value. Under SDOM, this
     equates to whether or not NODE has any children that have type
     SDOM:NODE-TYPE-TEXT

     This property is read-only

 -- Variable: sdom:value
 -- Variable: Attr.value
     Property type: String

     The value of NODE. Setting this value creates a new text node that
     is inserted as a child of NODE

     Errors on setting:
        * Throws SDOM:EXCEPTION-CODE-NO-MODIFICATION-ALLOWED-ERR if
          node is read-only

 -- Variable: sdom:owner-element
 -- Variable: Attr.ownerElement
     Property type: Node

     The element to which NODE is attached or #F if NODE is not in use

     This property is read-only

 -- Variable: sdom:schema-type-info
 -- Variable: Attr.schemaTypeInfo
     Property type: N/A

     SDOM does not currently support XML Schema; this property will
     always have the value #F

     This property is read-only

 -- Variable: sdom:is-id
 -- Variable: Attr.isId
     Property type: Boolean

     SDOM does not currently support XML Schema or DTD validation; this
     property will always have the value #F

     This property is read-only

9.1.6 Properties for Elements
-----------------------------

 -- Variable: sdom:tag-name
 -- Variable: Element.tagName
     Property type: String

     The name of NODE. This will be a qualified name if SDOM:LOCAL-NAME
     is not #F

     This property is read-only

 -- Variable: sdom:schema-type-info
 -- Variable: Element.schemaTypeInfo
     Property type: N/A

     SDOM does not currently support XML Schema; this property will
     always have the value #F

     This property is read-only

9.1.7 Properties for Document Type nodes
----------------------------------------

 -- Variable: sdom:name
 -- Variable: DocumentType.name
     Property type: String

     The name of the DTD represented by NODE

     This property is read-only

 -- Variable: sdom:entities
 -- Variable: DocumentType.entities
     Property type: List of nodes

     A list of nodes representing internal and external entities
     declared by NODE, not including duplicates or parameter entities

     This property is read-only

 -- Variable: sdom:notations
 -- Variable: DocumentType.notations
     Property type: List of nodes

     A list of nodes representing notations declared by NODE, not
     including duplicates

     This property is read-only

 -- Variable: sdom:public-id
 -- Variable: DocumentType.publicId
     Property type: String

     The public identifier of NODE

     This property is read-only

 -- Variable: sdom:system-id
 -- Variable: DocumentType.systemId
     Property type: String

     The system identifier of NODE

     This property is read-only

 -- Variable: sdom:internal-subset
 -- Variable: DocumentType.internalSubset
     Property type: String

     The internal subset represented by NODE or #F if there is none

     This property is read-only

9.1.8 Properties for Document nodes
-----------------------------------

 -- Variable: sdom:doc-type
 -- Variable: Document.doctype
     Property type: Node

     The node giving the Document Type Definition attached to NODE, or
     #F if none exists

     This property is read-only

 -- Variable: sdom:implementation
 -- Variable: Document.implementation
     Property type: N/A

     SDOM does not currently support the DOMImplementation interface;
     this property will always have the value #F

     This property is read-only

 -- Variable: sdom:document-element
 -- Variable: Document.documentElement
     Property type: Node

     The first (and only) child of NODE that has type
     SDOM:NODE-TYPE-ELEMENT, or #F if no such child exists

     This property is read-only

 -- Variable: sdom:input-encoding
 -- Variable: Document.inputEncoding
     Property type: String

     The encoding type used at the time of parsing, or #F if unknown;
     this property will always have the value #F under SDOM

     This property is read-only

 -- Variable: sdom:xml-encoding
 -- Variable: Document.xmlEncoding
     Property type: String

     The encoding type of the document to which NODE belongs, or #F if
     unknown; this property will always have the value #F under SDOM

     This property is read-only

 -- Variable: sdom:xml-standalone
 -- Variable: Document.xmlStandalone
     Property type: Boolean

     Whether the document to which NODE belongs is standalone, or #F if
     unknown; this property will always have the initial value #F under
     SDOM

     Errors on setting:
        * Throws SDOM:EXCEPTION-CODE-NOT-SUPPORTED-ERR if document does
          not support feature "XML"

 -- Variable: sdom:xml-version
 -- Variable: Document.xmlVersion
     Property type: String

     The version number of this document; this property will always
     have the initial value #F under SDOM

     Errors on setting:
        * Throws SDOM:EXCEPTION-CODE-NOT-SUPPORTED-ERR if document does
          not support feature "XML" or if document does not support
          version specified by new value

 -- Variable: sdom:strict-error-checking
 -- Variable: Document.strictErrorChecking
     Property type: Boolean

     Whether or not to perform strict error checking during document
     normalization.

 -- Variable: sdom:document-uri
 -- Variable: Document.documentURI
     Property type: String

     The location of NODE or #F if undefined

 -- Variable: sdom:dom-config
 -- Variable: Document.domConfig
     Property type: N/A

     SDOM does not currently support the DOMConfiguration interface;
     use SDOM:SET-DOM-CONFIG-PARAMETER! and
     SDOM:GET-DOM-CONFIG-PARAMETER to interact with the DOM
     configuration

     This property is read-only

Appendix A GNU Free Documentation License
*****************************************

                      Version 1.2, November 2002

     Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
     59 Temple Place, Suite 330, Boston, MA  02111-1307, USA

     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.

  0. PREAMBLE

     The purpose of this License is to make a manual, textbook, or other
     functional and useful document "free" in the sense of freedom: to
     assure everyone the effective freedom to copy and redistribute it,
     with or without modifying it, either commercially or
     noncommercially.  Secondarily, this License preserves for the
     author and publisher a way to get credit for their work, while not
     being considered responsible for modifications made by others.

     This License is a kind of "copyleft", which means that derivative
     works of the document must themselves be free in the same sense.
     It complements the GNU General Public License, which is a copyleft
     license designed for free software.

     We have designed this License in order to use it for manuals for
     free software, because free software needs free documentation: a
     free program should come with manuals providing the same freedoms
     that the software does.  But this License is not limited to
     software manuals; it can be used for any textual work, regardless
     of subject matter or whether it is published as a printed book.
     We recommend this License principally for works whose purpose is
     instruction or reference.

  1. APPLICABILITY AND DEFINITIONS

     This License applies to any manual or other work, in any medium,
     that contains a notice placed by the copyright holder saying it
     can be distributed under the terms of this License.  Such a notice
     grants a world-wide, royalty-free license, unlimited in duration,
     to use that work under the conditions stated herein.  The
     "Document", below, refers to any such manual or work.  Any member
     of the public is a licensee, and is addressed as "you".  You
     accept the license if you copy, modify or distribute the work in a
     way requiring permission under copyright law.

     A "Modified Version" of the Document means any work containing the
     Document or a portion of it, either copied verbatim, or with
     modifications and/or translated into another language.

     A "Secondary Section" is a named appendix or a front-matter section
     of the Document that deals exclusively with the relationship of the
     publishers or authors of the Document to the Document's overall
     subject (or to related matters) and contains nothing that could
     fall directly within that overall subject.  (Thus, if the Document
     is in part a textbook of mathematics, a Secondary Section may not
     explain any mathematics.)  The relationship could be a matter of
     historical connection with the subject or with related matters, or
     of legal, commercial, philosophical, ethical or political position
     regarding them.

     The "Invariant Sections" are certain Secondary Sections whose
     titles are designated, as being those of Invariant Sections, in
     the notice that says that the Document is released under this
     License.  If a section does not fit the above definition of
     Secondary then it is not allowed to be designated as Invariant.
     The Document may contain zero Invariant Sections.  If the Document
     does not identify any Invariant Sections then there are none.

     The "Cover Texts" are certain short passages of text that are
     listed, as Front-Cover Texts or Back-Cover Texts, in the notice
     that says that the Document is released under this License.  A
     Front-Cover Text may be at most 5 words, and a Back-Cover Text may
     be at most 25 words.

     A "Transparent" copy of the Document means a machine-readable copy,
     represented in a format whose specification is available to the
     general public, that is suitable for revising the document
     straightforwardly with generic text editors or (for images
     composed of pixels) generic paint programs or (for drawings) some
     widely available drawing editor, and that is suitable for input to
     text formatters or for automatic translation to a variety of
     formats suitable for input to text formatters.  A copy made in an
     otherwise Transparent file format whose markup, or absence of
     markup, has been arranged to thwart or discourage subsequent
     modification by readers is not Transparent.  An image format is
     not Transparent if used for any substantial amount of text.  A
     copy that is not "Transparent" is called "Opaque".

     Examples of suitable formats for Transparent copies include plain
     ASCII without markup, Texinfo input format, LaTeX input format,
     SGML or XML using a publicly available DTD, and
     standard-conforming simple HTML, PostScript or PDF designed for
     human modification.  Examples of transparent image formats include
     PNG, XCF and JPG.  Opaque formats include proprietary formats that
     can be read and edited only by proprietary word processors, SGML or
     XML for which the DTD and/or processing tools are not generally
     available, and the machine-generated HTML, PostScript or PDF
     produced by some word processors for output purposes only.

     The "Title Page" means, for a printed book, the title page itself,
     plus such following pages as are needed to hold, legibly, the
     material this License requires to appear in the title page.  For
     works in formats which do not have any title page as such, "Title
     Page" means the text near the most prominent appearance of the
     work's title, preceding the beginning of the body of the text.

     A section "Entitled XYZ" means a named subunit of the Document
     whose title either is precisely XYZ or contains XYZ in parentheses
     following text that translates XYZ in another language.  (Here XYZ
     stands for a specific section name mentioned below, such as
     "Acknowledgements", "Dedications", "Endorsements", or "History".)
     To "Preserve the Title" of such a section when you modify the
     Document means that it remains a section "Entitled XYZ" according
     to this definition.

     The Document may include Warranty Disclaimers next to the notice
     which states that this License applies to the Document.  These
     Warranty Disclaimers are considered to be included by reference in
     this License, but only as regards disclaiming warranties: any other
     implication that these Warranty Disclaimers may have is void and
     has no effect on the meaning of this License.

  2. VERBATIM COPYING

     You may copy and distribute the Document in any medium, either
     commercially or noncommercially, provided that this License, the
     copyright notices, and the license notice saying this License
     applies to the Document are reproduced in all copies, and that you
     add no other conditions whatsoever to those of this License.  You
     may not use technical measures to obstruct or control the reading
     or further copying of the copies you make or distribute.  However,
     you may accept compensation in exchange for copies.  If you
     distribute a large enough number of copies you must also follow
     the conditions in section 3.

     You may also lend copies, under the same conditions stated above,
     and you may publicly display copies.

  3. COPYING IN QUANTITY

     If you publish printed copies (or copies in media that commonly
     have printed covers) of the Document, numbering more than 100, and
     the Document's license notice requires Cover Texts, you must
     enclose the copies in covers that carry, clearly and legibly, all
     these Cover Texts: Front-Cover Texts on the front cover, and
     Back-Cover Texts on the back cover.  Both covers must also clearly
     and legibly identify you as the publisher of these copies.  The
     front cover must present the full title with all words of the
     title equally prominent and visible.  You may add other material
     on the covers in addition.  Copying with changes limited to the
     covers, as long as they preserve the title of the Document and
     satisfy these conditions, can be treated as verbatim copying in
     other respects.

     If the required texts for either cover are too voluminous to fit
     legibly, you should put the first ones listed (as many as fit
     reasonably) on the actual cover, and continue the rest onto
     adjacent pages.

     If you publish or distribute Opaque copies of the Document
     numbering more than 100, you must either include a
     machine-readable Transparent copy along with each Opaque copy, or
     state in or with each Opaque copy a computer-network location from
     which the general network-using public has access to download
     using public-standard network protocols a complete Transparent
     copy of the Document, free of added material.  If you use the
     latter option, you must take reasonably prudent steps, when you
     begin distribution of Opaque copies in quantity, to ensure that
     this Transparent copy will remain thus accessible at the stated
     location until at least one year after the last time you
     distribute an Opaque copy (directly or through your agents or
     retailers) of that edition to the public.

     It is requested, but not required, that you contact the authors of
     the Document well before redistributing any large number of
     copies, to give them a chance to provide you with an updated
     version of the Document.

  4. MODIFICATIONS

     You may copy and distribute a Modified Version of the Document
     under the conditions of sections 2 and 3 above, provided that you
     release the Modified Version under precisely this License, with
     the Modified Version filling the role of the Document, thus
     licensing distribution and modification of the Modified Version to
     whoever possesses a copy of it.  In addition, you must do these
     things in the Modified Version:

       A. Use in the Title Page (and on the covers, if any) a title
          distinct from that of the Document, and from those of
          previous versions (which should, if there were any, be listed
          in the History section of the Document).  You may use the
          same title as a previous version if the original publisher of
          that version gives permission.

       B. List on the Title Page, as authors, one or more persons or
          entities responsible for authorship of the modifications in
          the Modified Version, together with at least five of the
          principal authors of the Document (all of its principal
          authors, if it has fewer than five), unless they release you
          from this requirement.

       C. State on the Title page the name of the publisher of the
          Modified Version, as the publisher.

       D. Preserve all the copyright notices of the Document.

       E. Add an appropriate copyright notice for your modifications
          adjacent to the other copyright notices.

       F. Include, immediately after the copyright notices, a license
          notice giving the public permission to use the Modified
          Version under the terms of this License, in the form shown in
          the Addendum below.

       G. Preserve in that license notice the full lists of Invariant
          Sections and required Cover Texts given in the Document's
          license notice.

       H. Include an unaltered copy of this License.

       I. Preserve the section Entitled "History", Preserve its Title,
          and add to it an item stating at least the title, year, new
          authors, and publisher of the Modified Version as given on
          the Title Page.  If there is no section Entitled "History" in
          the Document, create one stating the title, year, authors,
          and publisher of the Document as given on its Title Page,
          then add an item describing the Modified Version as stated in
          the previous sentence.

       J. Preserve the network location, if any, given in the Document
          for public access to a Transparent copy of the Document, and
          likewise the network locations given in the Document for
          previous versions it was based on.  These may be placed in
          the "History" section.  You may omit a network location for a
          work that was published at least four years before the
          Document itself, or if the original publisher of the version
          it refers to gives permission.

       K. For any section Entitled "Acknowledgements" or "Dedications",
          Preserve the Title of the section, and preserve in the
          section all the substance and tone of each of the contributor
          acknowledgements and/or dedications given therein.

       L. Preserve all the Invariant Sections of the Document,
          unaltered in their text and in their titles.  Section numbers
          or the equivalent are not considered part of the section
          titles.

       M. Delete any section Entitled "Endorsements".  Such a section
          may not be included in the Modified Version.

       N. Do not retitle any existing section to be Entitled
          "Endorsements" or to conflict in title with any Invariant
          Section.

       O. Preserve any Warranty Disclaimers.

     If the Modified Version includes new front-matter sections or
     appendices that qualify as Secondary Sections and contain no
     material copied from the Document, you may at your option
     designate some or all of these sections as invariant.  To do this,
     add their titles to the list of Invariant Sections in the Modified
     Version's license notice.  These titles must be distinct from any
     other section titles.

     You may add a section Entitled "Endorsements", provided it contains
     nothing but endorsements of your Modified Version by various
     parties--for example, statements of peer review or that the text
     has been approved by an organization as the authoritative
     definition of a standard.

     You may add a passage of up to five words as a Front-Cover Text,
     and a passage of up to 25 words as a Back-Cover Text, to the end
     of the list of Cover Texts in the Modified Version.  Only one
     passage of Front-Cover Text and one of Back-Cover Text may be
     added by (or through arrangements made by) any one entity.  If the
     Document already includes a cover text for the same cover,
     previously added by you or by arrangement made by the same entity
     you are acting on behalf of, you may not add another; but you may
     replace the old one, on explicit permission from the previous
     publisher that added the old one.

     The author(s) and publisher(s) of the Document do not by this
     License give permission to use their names for publicity for or to
     assert or imply endorsement of any Modified Version.

  5. COMBINING DOCUMENTS

     You may combine the Document with other documents released under
     this License, under the terms defined in section 4 above for
     modified versions, provided that you include in the combination
     all of the Invariant Sections of all of the original documents,
     unmodified, and list them all as Invariant Sections of your
     combined work in its license notice, and that you preserve all
     their Warranty Disclaimers.

     The combined work need only contain one copy of this License, and
     multiple identical Invariant Sections may be replaced with a single
     copy.  If there are multiple Invariant Sections with the same name
     but different contents, make the title of each such section unique
     by adding at the end of it, in parentheses, the name of the
     original author or publisher of that section if known, or else a
     unique number.  Make the same adjustment to the section titles in
     the list of Invariant Sections in the license notice of the
     combined work.

     In the combination, you must combine any sections Entitled
     "History" in the various original documents, forming one section
     Entitled "History"; likewise combine any sections Entitled
     "Acknowledgements", and any sections Entitled "Dedications".  You
     must delete all sections Entitled "Endorsements."

  6. COLLECTIONS OF DOCUMENTS

     You may make a collection consisting of the Document and other
     documents released under this License, and replace the individual
     copies of this License in the various documents with a single copy
     that is included in the collection, provided that you follow the
     rules of this License for verbatim copying of each of the
     documents in all other respects.

     You may extract a single document from such a collection, and
     distribute it individually under this License, provided you insert
     a copy of this License into the extracted document, and follow
     this License in all other respects regarding verbatim copying of
     that document.

  7. AGGREGATION WITH INDEPENDENT WORKS

     A compilation of the Document or its derivatives with other
     separate and independent documents or works, in or on a volume of
     a storage or distribution medium, is called an "aggregate" if the
     copyright resulting from the compilation is not used to limit the
     legal rights of the compilation's users beyond what the individual
     works permit.  When the Document is included in an aggregate, this
     License does not apply to the other works in the aggregate which
     are not themselves derivative works of the Document.

     If the Cover Text requirement of section 3 is applicable to these
     copies of the Document, then if the Document is less than one half
     of the entire aggregate, the Document's Cover Texts may be placed
     on covers that bracket the Document within the aggregate, or the
     electronic equivalent of covers if the Document is in electronic
     form.  Otherwise they must appear on printed covers that bracket
     the whole aggregate.

  8. TRANSLATION

     Translation is considered a kind of modification, so you may
     distribute translations of the Document under the terms of section
     4.  Replacing Invariant Sections with translations requires special
     permission from their copyright holders, but you may include
     translations of some or all Invariant Sections in addition to the
     original versions of these Invariant Sections.  You may include a
     translation of this License, and all the license notices in the
     Document, and any Warranty Disclaimers, provided that you also
     include the original English version of this License and the
     original versions of those notices and disclaimers.  In case of a
     disagreement between the translation and the original version of
     this License or a notice or disclaimer, the original version will
     prevail.

     If a section in the Document is Entitled "Acknowledgements",
     "Dedications", or "History", the requirement (section 4) to
     Preserve its Title (section 1) will typically require changing the
     actual title.

  9. TERMINATION

     You may not copy, modify, sublicense, or distribute the Document
     except as expressly provided for under this License.  Any other
     attempt to copy, modify, sublicense or distribute the Document is
     void, and will automatically terminate your rights under this
     License.  However, parties who have received copies, or rights,
     from you under this License will not have their licenses
     terminated so long as such parties remain in full compliance.

 10. FUTURE REVISIONS OF THIS LICENSE

     The Free Software Foundation may publish new, revised versions of
     the GNU Free Documentation License from time to time.  Such new
     versions will be similar in spirit to the present version, but may
     differ in detail to address new problems or concerns.  See
     `http://www.gnu.org/copyleft/'.

     Each version of the License is given a distinguishing version
     number.  If the Document specifies that a particular numbered
     version of this License "or any later version" applies to it, you
     have the option of following the terms and conditions either of
     that specified version or of any later version that has been
     published (not as a draft) by the Free Software Foundation.  If
     the Document does not specify a version number of this License,
     you may choose any version ever published (not as a draft) by the
     Free Software Foundation.

A.0.1 ADDENDUM: How to use this License for your documents
----------------------------------------------------------

To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and license
notices just after the title page:

       Copyright (C)  YEAR  YOUR NAME.
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.2
       or any later version published by the Free Software Foundation;
       with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
       Texts.  A copy of the license is included in the section entitled ``GNU
       Free Documentation License''.

   If you have Invariant Sections, Front-Cover Texts and Back-Cover
Texts, replace the "with...Texts." line with this:

         with the Invariant Sections being LIST THEIR TITLES, with
         the Front-Cover Texts being LIST, and with the Back-Cover Texts
         being LIST.

   If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.

   If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License, to
permit their use in free software.