WebIt! implements an abstract datatype for the XML Infoset, in terms of the API described in this section. The concrete datatype used by this API is SXML.
normalized-sxml
parameter
By default, WebIt! functions and syntax can process non-normalized SXML. However, there is a performance penalty for this. normalized-sxml
may be used to restrict WebIt! to processing a particular style of normalized SXML. The default value of #f
enables processing of non-normalized SXML. Set this parameter to #t
to restrict WebIt! to normalized SXML.
make-xml-document
function
make-xml-document :: list-of-nodes -> xml-document
This function construction a document node from a list of nodes. The list should include exactly one xml-element node.
xml-document?
function
xml-document? :: node -> boolean
Returns #t
if its argument is an xml-document node, otherwise #f
.
xml-document-dtd-info
function
xml-document-dtd-info :: xml-document -> xml-dtd-info
Returns the document's xml-dtd-info, if one is present, otherwise #f
.
xml-document-content
function
xml-document-content :: xml-document -> xml-element
Returns the document's root element.
xml-document-body
function
xml-document-content :: xml-document -> nodeset
Returns a list of the document's body nodes.
make-xml-element
function
make-xml-element :: tag attribute-list node-list -> xml-element
The element tag is a symbol.
The attribute-list is a list of attribute nodes: a list of an attribute tag and a string, number or boolean.
A node-list is a (possibly null) list of XML nodes.
make-xml-element/ns
function
make-xml-element/ns :: tag ns-list attribute-list node-list -> xml-element
The element tag, tag, is a symbol.
ns-list is a list of namespace bindings. Each namespace binding is a list of a namespace uri (string) and a prefix (symbol).
The attribute-list is a list of attribute nodes: a list of an attribute tag and a string, number or boolean.
A node-list is a (possibly null) list of XML nodes.
xml-element?
function
xml-element? :: node -> boolean
Returns #t
if its argument is an xml-element node, otherwise #f
.
xml-element-tag
function
xml-element-tag :: xml-element -> symbol
Returns the tag (symbol) of an element node. This tag is either the local name of the element (for locally named element), or the concatenation of the namespace URI to which the element belongs and the element's local name, separated by a colon.
xml-element-local-name
function
xml-element-local-name :: xml-element -> symbol
Returns the local-name (symbol) of an element node.
xml-element-ns-uri
function
xml-element-local-name :: xml-element -> symbol
Returns the namespace URI to which the element belongs, #f
.
xml-element-ns-list
function
xml-element-ns-list :: xml-element -> (listof xml-namespace-binding)
Returns a list of namespace prefix bindings associated with this element.
xml-element-attributes
function
xml-element-attributes :: xml-element -> (listof xml-attribute)
Returns a list of attributes of this element.
xml-element-contents
function
xml-element-contents :: xml-element -> (listof node)
Returns a nodeset of the children of this element.
make-xml-attribute
function
make-xml-attribute :: tag value -> (list-of symbol string|number|boolean)
The attribute tag is a symbol.
The value of an attribute may be a string, number or boolean.
xml-attribute-tag
function
xml-attribute-tag :: xml-attribute -> symbol
Returns the tag (symbol) of an attribute node. This tag is either the local name of the attribute (for locally named attributes), or the concatenation of the namespace URI to which the attribute belongs and the attribute's local name, separated by a colon.
xml-attribute-local-name
function
xml-attribute-local-name :: xml-attribute -> symbol
Returns the local-name (symbol) of an attribute node.
xml-attribute-ns-uri
function
xml-attribute-local-name :: xml-attribute -> symbol
Returns the namespace URI to which the attribute belongs, #f
.
xml-attribute-value
function
xml-attribute-value :: xml-attribute -> string|number|boolean
Returns the value of an attribute node.
make-xml-comment
function
make-xml-comment :: string -> xml-comment
This function constructs an xml-comment object with its argument as the comment text.
xml-comment?
function
xml-comment? :: node -> boolean
This function returns #t
if its argument is an xml-comment, otherwise #f
.
xml-comment-text
function
xml-comment-text :: xml-comment -> string
Returns the text of an xml-comment node.
make-xml-pi
function
make-xml-pi :: symbol string -> xml-pi
This function has to arguments: a PI target (symbol) and PI text (a string). Returns a new xml-pi object.
xml-pi?
function
xml-pi? :: node -> boolean
This function returns #t
if its argument is an xml-comment, otherwise #f
.
xml-pi-target
function
xml-pi-target :: xml-pi -> symbol
This function returns it's argument's PI target.
xml-pi-text
function
xml-pi-text :: xml-pi -> symbol
This function returns it's argument's PI text.
make-xml-entity
function
make-xml-entity :: string string -> xml-entity
This function takes two arguments of type string: a public-id and a system-id, and a returns a new xml-entity object.
xml-entity?
function
xml-entity? :: node -> boolean
This function returns #t
if its argument is an xml-entity, otherwise #f
.
xml-entity-public-id
function
xml-entity-public-id :: xml-entity -> string
This function returns it's argument's public-id.
xml-entity-system-id
function
xml-entity-system-id :: xml-entity -> string
This function returns it's argument's system-id.
make-xml-ns-binding
function
make-xml-ns-binding :: symbol string -> (list symbol string)
This function takes two arguments: a namespace prefix (symbol) and a namespace URI (string), and returns a new namespace prefix binding.
xml-ns-binding-prefix
function
xml-ns-binding-prefix :: (list symbol string) -> symbol
This function returns the namespace prefix from its argument.
xml-ns-binding-ns-url
function
xml-ns-binding-ns-url :: (list symbol string) -> string
This function returns the namespace URI from its argument.
make-xml-dtd-info
function
make-xml-dtd-info :: symbol string -> xml-dtd-info
This function takes two arguments: a name (symbol) and a system (string). Returns a new xml-dtd-info object.
xml-dtd-info?
function
xml-dtd-info? :: node -> boolean
This function returns #t
if its argument is an xml-dtd-info or xml-dtd-info/public object, otherwise #f
.
xml-dtd-info-name
function
xml-dtd-info-name :: xml-dtd-info -> symbol
This function returns it's argument's name field.
xml-dtd-info-system
function
xml-dtd-info-system :: xml-dtd-info -> string
This function returns it's argument's system field.
make-xml-dtd-info/public
function
make-xml-dtd-info/public :: symbol string string -> xml-dtd-info/public
This function takes three arguments: a name (symbol), a system (string), and a public (string). Returns a new xml-dtd-info/public object.
xml-dtd-info/public?
function
xml-dtd-info/public? :: node -> boolean
This function returns #t
if its argument is an xml-dtd-info/public, otherwise #f
.
xml-dtd-info/public-public
function
xml-dtd-info/public-public :: xml-dtd-info/public -> string
This function returns it's argument's public field.
nodeset?
function
nodeset? :: any -> boolean
This function returns #t
if its argument is a list which does not begin with a symbol, otherwise #f
.
has-attribute?
function
has-attribute? :: symbol (listof xml-attribute) -> (xml-attribute | #f)
This function searches a list of attributes for the for the requested attribute. Returns the matching attribute, otherwise #f
.
bind-namespaces
syntax
This form is used to introduce namespace prefix bindings, and to attach these bindings to an xml-element object.
The grammar for bind-namespaces
is:
(bind-namespaces ([prefix-symbol uri-string] ...) expression)
Expression must evaluate to an xml-element. bind-namespaces
returns a new xml-element object, with the new namespace prefix bindings.