SDOM MANUAL-EDITION 0.4.2

Table of Contents


Next: , Up: (dir)

The SDOM Manual

This manual describes the SDOM Scheme module.

Copyright © 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

Table of Contents


Next: , Previous: Top, Up: Top

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.


Next: , Previous: Introduction, Up: Top

2 Adherence to W3C DOM


Next: , Up: 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.

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.


Previous: Naming conventions, Up: Adherence to W3C DOM

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:


Next: , Previous: Adherence to W3C DOM, Up: Top

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:


Next: , Previous: Compatibility with SXML, Up: Top

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.


Next: , Previous: Document parsing, Up: Top

5 Implementation details


Next: , Up: 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.


Previous: Interior and exterior node representations, Up: Implementation details

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.)


Next: , Previous: Implementation details, Up: Top

6 Event handling


Next: , Up: Event handling

6.1 Event API


Previous: Event API, Up: Event handling

6.2 Event property reference


Up: 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


Next: , Up: Properties for Events
6.2.1.1 Properties for Custom Events


Next: , Previous: Properties for Custom Events, Up: Properties for Events
6.2.1.2 Properties for UI Events

— Variable: sdom:view
— Variable: UIEvent.view

— Variable: sdom:detail
— Variable: UIEvent.detail


Previous: Properties for UI Events, Up: Properties for Events
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


Next: , Previous: Event handling, Up: Top

7 Type reference


Next: , Up: 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)


Next: , Previous: Node types, Up: Type reference

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


Next: , Previous: Event types, Up: Type reference

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)


Next: , Previous: Exception types, Up: Type reference

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)


Previous: User data event types, Up: Type reference

7.5 SDOM constants


Next: , Previous: Type reference, Up: Top

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.


Next: , Up: SDOM API reference

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-section content, as string
sdom:node-type-entity-reference entity name, as string
sdom:node-type-entity
sdom:node-type-processing-instruction target, 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")
     


Next: , Previous: Node creation, Up: SDOM API reference

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:

Events:

— 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:

Events:

— 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:

— 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:

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


Next: , Previous: Node manipulation, Up: SDOM API reference

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


Next: , Previous: Node predicates, Up: SDOM API reference

8.4 Properties and configuration

— Function: sdom:set-dom-property! node property value

Errors:

— Function: sdom:get-dom-property node property

Errors:


Up: Properties and configuration

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:

— 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:

— 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.


Next: , Previous: Properties and configuration, Up: SDOM API reference

8.5 Namespaces


Next: , Previous: Namespaces, Up: SDOM API reference

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:

— 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:

— 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:


Next: , Previous: Functions on Documents, Up: SDOM API reference

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:

— Function: sdom:set-attribute-node! element attr
— Function: Element.setAttributeNode

Attaches the attr node attr as a new attribute of element element. Errors:

— Function: sdom:remove-attribute-node! element attr
— Function: Element.removeAttributeNode

Removes the attr node attr from its owner element, element.

Errors:

— 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:

— 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:

— 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:

— 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:

— 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:


Next: , Previous: Functions on Elements, Up: SDOM API reference

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:


Previous: Functions on Text nodes, Up: SDOM API reference

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.


Next: , Previous: SDOM API reference, Up: Top

9 SDOM property reference


Up: 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:

— 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:

— 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:


Next: , Up: Properties for Nodes

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:

— 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


Up: Properties for Character Data nodes
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 belongs1; #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


Next: , Previous: Properties for Character Data nodes, Up: Properties for Nodes

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


Next: , Previous: Properties for Notation nodes, Up: Properties for Nodes

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


Next: , Previous: Properties for Entities, Up: Properties for Nodes

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:


Next: , Previous: Properties for Processing Instruction nodes, Up: Properties for Nodes

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:

— 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


Next: , Previous: Properties for Attr nodes, Up: Properties for Nodes

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


Next: , Previous: Properties for Elements, Up: Properties for Nodes

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


Previous: Properties for Document Type nodes, Up: Properties for Nodes

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:

— 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: