afnix-xml






xml ‐ standard xml module

The Standard XMLmodule is an original implementation of the
XML markup language. The module provides the necessary
objects for parsing a xml description as well as
manipulating the parsed tree. The module can be extended to
a service as a mean to act as a XML processor. The module
also provides the support for a simple modelwhich enable the
quick parsing of documents with a relaxed rule checking
approach.

     representationXMLtree
A xml document is represented with a tree. At the top of the
tree is the XmlRootobject. The root object is not part of
the document, but acts as the primary container for other
objects. A xml document starts with a root node and all
other child elements are XmlNodeobjects.

     objectNodebase
The xml tree is built with the XmlNodeobject. The node
object has different derivation depending on the required
representation. For example, the XmlRootobject is derived
from the XmlNodeobject. A node object can have child object
unless the node is marked as an empty node. Trying to add
node to an empty node results in an exception. A node can
also be marked empty by the user. This situation typically
arises with tag node which are used alone such like the
<br/>xhtml empty tag or an empty paragraph <p/>. Although a
xml node cannot be constructed directly, there is a
predicate node‐pthat can be used to assert the node type.

# check a node
assert true (afnix:xml:node‐p node)

The add‐childmethod adds a child node to the calling node.
If the calling node is marked empty, an exception is raised
when attempting to add the node. There is no limit for the
number of nodes to add. In particular, when a text is to be
added, care should be taken that there is no markup within
that text. In doubt, the parsemethod should be used.

# parse a text and add 3 child nodes
p:parse "The quick brown <b>fox</b>
jumps over the lazy dog"

In the previous example, the first child node is a
XmlTextnode with the value The quick brown . The second node
is a XmlTagnode with name b. Finally, the third node is also
a XmlTextnode with the value jumps over the lazy dog. It
should be noted that the tag node has a child XmlTextnode
with the value fox. This example also illustrates the power
of the parsemethod which considerably simplify the creation
of a xml tree. Finally, there is a subtle subject to be
treated later which concerns the use of character









                             ‐2‐


referencewith the parsemethod. Like any other xml parser,
character references are evaluated during the parsing phase,
thus providing no mechanism to create such reference. For
this reason, a special class called XmlCrefis provided in
the module.

     Tagobject
The XmlTagclass is one of the most important class as it
holds most of the xml constructs. A tag is defined by a
name, a set of attributes and eventually a content. In its
simplest form, a tag is created by name. With an additional
boolean parameter, the tag can be marked as an empty node.

# create an empty paragraph tag
const p (afnix:xml:XmlTag "p" true)

Adding attributes to a tag is imply a matter of method call.
The add‐attributemethod operates with a Propertyobject while
the set‐attributeoperates with a name and a literal value.
As a matter of fact, the attributes are stored internally as
a property list.

# <p class="text">
# create a paragraph tag
const p (afnix:xml:XmlTag "p")
# set the class attribute
p:set‐attribute "class" "text"

The node empty flag determines whether or not there is a end
tag associated with a tag. If the empty flag is false, the
node can have children nodes and is associated with a end
tag. With the empty flag set, there is no child nodes. Such
situation corresponds to the xml />notation.

# <br/>
# create a br empty tag
const br (afnix:xml:XmlTag "br" true)


     Textobjects
The xml module provides two types of xml text node. The
basic object is the XmlTextnode which is designed to hold
some text without markup. It is this kind of nodes which is
automatically instantiated by the parsemethod, as described
earlier. The other object is the XmlDatawhich corresponds to
the xml CDATAspecial markup. With a character data node, the
characters are not interpreted, including those that
indicate markup starts like <or end like >. The XmlDatais
particularly used to store scripts or other program
textinside a xml description. As an example, it is
recommended to use a character data node inside a script tag
with xhtml.











                             ‐3‐


     Documentreading
A xml document is read by scanning an input stream an
building a representation of the xml tree.

     objectThedocument
The XmlDocumentobject is a special object is designed to
ease the reading process of an xml document. The process of
creating a xml document consists of creating a document
object, then binding a xml reader, parsing the input stream
and finally storing the root node. When the operation is
completed, the root node is available in the document
object.

# create a xml document
const xdoc (afnix:xml:XmlDocument "example.xml")
# get the root node
const rppt (xdoc:get‐root)


     nodeTheroot
When a document is parsed, the root node holds all the
elements and markup sequentially. At this stage, it shall be
noted that the element data are not expanded. Unlike a
normal XML reader, the parameter entity are kept in the node
data, are expended later by the XML processor.

     operationsNodetree
The class XneTreeprovides a single framework to operate on a
node and its associated tree. Since a node always carries a
sub‐tree, the node treeterm will be used to reference it.

     nodeCreatinga
A node tree is created either from a node at construction or
with the help of the set‐nodemethod.

# create a node tree at construction
const tree (afnix:xml:XneTree root)
# change the node tree
tree:set‐node node

Once a tree is created, various methods are provided to
operate on the whole tree. The depthmethod returns the depth
of the node tree. The get‐nodemethods returns the the node
associated with the tree.

# get the tree depth
println (tree:depth)


     Namespaceoperations
The concept of namespaceis an extension to the xml standard.
Unlike other programming language, the concept of namespace
is designed to establish a binding between a name and an
uri. Such binding permits to establish a scope for tags









                             ‐4‐


without too much burden. In the xml namespace terminology,
an expanded nameis composed of a prefixand a local name. The
basic operations provided at the tree level is the prefix
cancellation and the tree prefix setting.

# clear the prefix for the whole tree
tree:clear‐prefix
# set a prefix for the whole tree
tree:set‐prefix "afnix"

The set‐prefixchanges the prefix for the whole tree. It is
not necessary to clear first the prefix.

     Attributeoperations
Each node in the node tree can have its attribute list
modified in a single operation. The first operation is to
clear all attributes for all nodes. Although this operation
might be useful, it should be carried with caution. The
attributes can also cleared more selectively by using the
tag name as a filter. For more complex operation, the clear‐
attributemethod of the XmlTagis the definitive answer.

# clear all attributes
tree:clear‐attribute
# clear all attributes by tag name
tree:clear‐attribute "p"

The set‐attributemethod sets an attribute to the whole tree.
The first argument is the attribute name and the second is a
literal value. For more selective operations, the set‐
attributemethod can be also called at the tag level.

# clear all attributes
tree:set‐attribute "class" "text"

When it comes to set attributes, there is a special
operation related to the "id" attribute. Such attribute is
supposed to be unique for the whole tree. For this reason,
the generate‐idgenerates a unique id for each node and
assign the id attribute. The attribute is unique at the time
of the call. If the tree is modified, and in particular, if
new node are added, the method must be called again to
regenerate the node id.

# set a unique id for all nodes
tree:generate‐id


     andNodelocation
The node location is the ability to locate one or several
nodes in a xml tree. A node is generally located by name,
path or id. Once a node has been located, it can be
processed. Note that the node locator operates operates
almost exclusively with XmlTagnode, although it might not be









                             ‐5‐


always the case.

     Nodeselection
The process of finding a child node is obtained with the
help of the XneCondclass combined with the selectmethod of
the XneTreeObject. The selectmethod traverses the whole tree
and attempts to match a condition for each node. If the
condition is evaluated successfully for a node, the node is
added in the result vector. Note that the tree can be
traversed entirely or with only the first layer of children.

# creating a condition node
const xcnd (afnix:xml:XneCond)
# create a tree with a root node
const tree (afnix:xml:XneTree root)
# select all nodes for that condition
trans result (tree:select xcnd)

In the previous example, the condition object is empty. This
means that there is no condition, and thus works for all
nodes. This previous example will return all nodes in the
tree.

     Nodecondition
The XmlCondclass provides several method to add a
conditions. The addmethod is the method of choice to add a
condition. The method operates with a condition type and a
literal. Note that the object can contain several
conditions.

# creating a condition node
const xcnd (afnix:xml:XneCond)
# add a condition by name
xcnd:add afnix:xml:xne:NAME "p"

In the previous example, a condition is designed to operate
with a tag name. Upon a call to the selectmethod with this
condition, all nodes in the tree that have the tag name
pwill be selected.

# creating a condition node
const xcnd (afnix:xml:XneCond)
# add a condition by name
xcnd:add afnix:xml:xne:NAME "p"
# add an index condition
xcnd:add afnix:xml:xne:INDEX 0

In the previous example, a condition is designed to operate
with a tag name and index. Upon a call to the selectmethod
with this condition, all nodes in the tree that have the tag
name pand those child index is 0 will be selected.

     Selectionresult
The node selection operates by default on the whole tree.









                             ‐6‐


The selectmethod, when called with a second boolean argument
can restrict the search to the child nodes.

# creating a condition node
const xcnd (afnix:xml:XneCond)
# create a tree with a root node
const tree (afnix:xml:XneTree root)
# select all nodes for that condition
trans result (tree:select xcnd false)

The selection results is stored in a vector object. The node
order corresponds to the tree order obtained with a depth
first search approach.

     nodeSimplemodel
The XML simple model is designed to simplify the
interpretation of a general sgml document such like, html or
xhtml document. In the simple model approach, there is no
tree. Instead, a vector of simple nodes is built, and a
document interface can be used to access the nodes.
Therefore, this simple model should be considered as a mean
to quickly parse document, but should not be used when tree
operations come into play. In such case, the xml model is by
far more appropriate. The simple model can be used to parse
a html document for instance. Note also that the simple
model is a relaxed model in terms of parsing rules. For
example, the tag start/end consistency is not checked and
the attribute parsing is not aggressive as it can be found
generally in poorly written html document.  In the simple
model, a XsmNodeis just a text place holder. The node
transports its type which can be either text, tag, reference
of end node. For the tag node, a subtype that identifies
reserved nodes versus normal type is also available.

     nodeCreatinga
A xsm node is created by name or byte and name. In the first
case, the node is a text node. In the second case, the node
subtype is automatically detected for tag node.

# create a xsm text node
const ntxt (afnix:xml:XsmNode "afnix">
  # create a xsm tag node
  const ntag (
    afnix:xml:XsmNode afnix:xml:XsmNode:TAG "afnix">

Note that the text corresponds to the node content. For
example, the string "!‐‐ example ‐‐" might corresponds to a
comment in html which is to say a reserved tag when the type
is tag or a simple text if the type is a text node. A
reserved tag is defined by a string which start either with
the ’!’ character or the ’[’ character.

# create a reserved tag
const rtag (









                             ‐7‐


  afnix:xml:XsmNode afnix:xml:XsmNode:TAG
  "!‐‐ example ‐‐")


     Noderepresentation
The xsm node is a literal node. This means that the to‐
stringand to‐literalmethods are available. When the to‐
literalmethod is called, the node text is automatically
formatted to reflect the node type.

# create a reserved tag
const rtag (
  afnix:xml:XsmNode afnix:xml:XsmNode:TAG
  "!‐‐ example ‐‐")
# print the node literal
rtag:to‐literal # <!‐‐ example ‐‐>

If the node is a reference node, the node literal is
represented with the original definition while the to‐
stringmethod will produce the corresponding character if it
known.

     Nodeinformation
With a xsm node, the operation are a limited number of node
informationoperations. The get‐namemethod returns the first
name found in a node. If the node is a normal tag, the get‐
namewill return the tag name. For the other node, the method
will return the first available string. This also means,
that the method will behave correctly with end tag node.

# create a tag node
const ntag (
  afnix:xml:XsmNode afnix:xml:XsmNode:TAG "afnix">
  # get the tag name
  ntag:get‐name

There is a predicate for all types. For example, the text‐
ppredicate returns true if the node is a text node. The tag‐
ppredicate returns true if the node is a normal or reserved
tag.

     Documentreading
A document is read in a way similar to the XmlDocumentwith
the help of the XsmDocumentobject. Once created, the
document holds a vector of nodes.

     objectThedocument
The XsmDocumentobject is a special xsm object designed to
ease the reading process of a document. The process of
creating a document consists of creating a document object,
then binding a xsm reader, parsing the input stream and
storing the nodes in a vector. When the operation is
completed, the vector can be accessed by index.










                             ‐8‐


# create a xms document
const xdoc (afnix:xml:XsmDocument "example.htm")
# get the document length
xdoc:length


     objectNodeinformation
The XsoInfoobject is a node information object designed to
hold a node name, an attributes list and eventually a text
associated with the node. For example, if a html document
contains a anchor node, the associated information node,
will have the anchoring text stored as the node information
text.

# create a xso node by name and text
const info (afnix:xml:XsoInfo "a" "click here")


     operationsSimplemodel
The XsmDocumentis designed to perform simple operations such
like searching all nodes that matches a particular name.
While this operation can be done easily, it is done in such
a way that a vector of node informationis returned instead
of a vector of nodes which can always be constructed with a
simple loop.

# create a xsm document
const xdoc (afnix:xml:XsmDocument "example.htm")
# get all node named "a" ‐ forcing lower case
xdoc:get‐info‐vector "a" true




     XmlNode
The XmlNodeclass is the base class used to represent the xml
tree. The tree is built as a vector of nodes. Each node owns
as well its parent node. Walking in the tree is achieved by
taking the child node and then moving to the child and/or
next node. The node also manages an empty flags. It the
empty flag is set, it is an error to add child nodes.

     Predicate

     node‐p

     Inheritance

     Object

     Methods

     Stringto‐text‐>
     The to‐textmethod returns a text representation of the









                             ‐9‐


     tree content. Unlike the write method, the tag are not
     generated, but rather the text content is accumulated.
     This method is useful tor read the node content. If a
     node does not have text, the nil string is returned.

     nonewrite‐>
     The writemethod write the node contents as well as the
     child nodes to an output stream argument or a buffer.
     When node is written, the method attempts to use the
     stream encoding in such way that the contents fits into
     the requested output encoding. Without argument, the
     node is written to the interpreter output stream. with
     one argument, the node is written to the specified
     stream or buffer.

     Booleanname‐p‐>
     The name‐ppredicate checks if the name matches the node
     name. Care should be taken that not all node have a
     name, and in such case, the false value is returned.
     This method is useful when the node is a tag.

     Booleanattribute‐p‐>
     The attribute‐ppredicate checks if there is a node
     attribute that matches the string argument name. In the
     first form, the predicate returns true is an attribute
     exists with the name argument. In the second form, the
     predicate returns true if the attribute name and value
     matches the arguments. The first argument is the
     attribute name. The second argument is the attribute
     value. Not all nodes have attributes. In such case, the
     predicate always returns false.

     noneparse‐>
     The parsemethod parses the string argument and adds the
     results as a set of child node to the calling node. If
     the node is an empty node, the method will almost fail.
     This method should be used when an attempt is made to
     add some text that may contain some xml tags.

     XmlNodeget‐parent‐>
     The get‐parentmethod returns the parent node. If the
     node is the root node, nil is returned.

     noneset‐parent‐>
     The set‐parentmethod sets the parent node.

     XmlNodecopy‐>
     The copymethod copy the node tree by regenerating a new
     tree.

     nonedel‐child‐>
     The del‐childmethod deletes one or several child nodes.
     In the first form, the children is deleted either by
     index or by name. When a string argument is used,









                            ‐10‐


     several node might be removed. In the second form, the
     child node name and attribute name must be matched. In
     the third form, the child node name, attribute name and
     value must be matched.

     nonedel‐attribute‐child‐>
     The del‐attribute‐childmethod deletes one or several
     child nodes. In the first form, the children are
     deleted by attribute name. In the second form, the
     children are delete by attribute name and value.

     noneclear‐child‐>
     The clear‐childmethod clear the child node list,
     leaving the node without child node.

     noneadd‐child‐>
     The add‐childmethod adds a node argument as a child
     node to the calling node. In the first form, the node
     is added at the end of the node list. In the second
     form, the node is added by index and all subsequent
     nodes are shifted by one position.

     XmlNodeget‐child‐>
     The get‐childmethod returns a child node by index or by
     name. If the calling argument is an integer, the node
     is returned by index. If the calling argument is a
     string, the node is returned by name. If the node
     cannot be found, nil is returned raised.

     Integerget‐index‐>
     The gett‐indexmethod returns a child node index. The
     node argument is the node to find as a child node. If
     the node is not found, an exception is raised.

     nonemerge‐>
     The mergemethod merge an existing node with another
     one. The first argument is the source node used for
     merging. The second argument the child node index to
     merge. The method operates by first removing the child
     node at the specified index and then add in position,
     the child nodes of the source node.

     Booleannil‐child‐p‐>
     The nil‐child‐ppredicate returns true if the node does
     not have a child node.

     Booleanchild‐p‐>
     The child‐ppredicate returns true if the node has a
     child with a node name argument. In the first form, the
     name is to be matched by the predicate. In the second
     form, the node nae and the attribute name must be
     matched. In the third form, the node name, attribute
     name and value must be matched.










                            ‐11‐


     Booleanattribute‐child‐p‐>
     The attribute‐child‐ppredicate returns true if the node
     has a child with an attribute name argument. In the
     first form, the attribute name must be matched. In the
     second form, the attribute name and value must be
     matched.

     XmlNodelookup‐child‐>
     The lookup‐childmethod returns a child node by name.
     Unlike the get‐childmethod, the method raises an
     exception if the node cannot be found.

     Integerchild‐length‐>
     The child‐lengthmethod returns the number of children
     nodes. In the first form, without argument, the total
     number of children nodes is returned. In the second
     form, the total number of nodes that match the tag
     argument name is returned.

     Integerget‐source‐line‐>
     The get‐source‐linemethod returns the node source line
     number if any.

     noneset‐source‐line‐>
     The set‐source‐linemethod sets the node source line
     number.

     Stringget‐source‐name‐>
     The get‐source‐namemethod returns the node source name
     if any.

     noneset‐source‐name‐>
     The set‐source‐namemethod sets the node source name.

     XmlTag
The XmlTagclass is the base class used to represent a xml
tag. A tag is defined with a name and an attribute list. The
tag is derived from the xml node class and is not marked
empty by default.

     Predicate

     tag‐p

     Inheritance

     XmlNode

     Constructors

     XmlTag(String)
     The XmlTagconstructor creates a tag node. The node is
     not marked empty.










                            ‐12‐


     Boolean)XmlTag(String
     The XmlTagconstructor creates a tag node. The first
     argument is the tag name. The second argument is the
     empty flag.

     Methods

     noneset‐name‐>
     The set‐namemethod sets the tag name.

     Stringget‐name‐>
     The get‐namemethod returns the tag name.

     noneclear‐attribute‐>
     The clear‐attributemethod clear the node attribute
     list.

     noneadd‐attribute‐>
     The add‐attributemethod adds a new attribute to the
     tag. The attribute must be new for this method to
     succeed. In doubt, the set‐attributeis preferable.

     noneset‐attribute‐>
     The set‐attributemethod sets an attribute to the tag.
     The first argument is the attribute name. The second
     argument is the attribute value. If the attribute
     already exists, the old value is replaced with the new
     one.

     Propertyget‐attribute‐>
     The get‐attributemethod returns a tag attribute in the
     form o a property object. With an integer object, the
     attribute is returned by index. With a string object,
     the property is return by name. If the property is not
     found, nil is returned.

     Stringget‐attribute‐value‐>
     The get‐attribute‐valuemethod returns a tag attribute
     value by name. The string argument is the attribute
     name. If the property is not found, an exception is
     raised.

     Propertylookup‐attribute‐>
     The lookup‐attributemethod returns a tag attribute by
     name in the form of a property. The string argument is
     the attribute name. If the property is not found, an
     exception is raised.

     Integerattribute‐length‐>
     The attribute‐lengthmethod returns the number of
     attributes.

     XmlText
The XmlTextclass is the xml text node. A text node is









                            ‐13‐


directly built by the xml reader and the content placed into
a string. By definition, a text node is an empty node.

     Predicate

     text‐p

     Inheritance

     XmlNode

     Constructors

     XmlText(none)
     The XmlTextconstructor creates a default text node. By
     definition, a text node is an empty node.

     XmlText(String)
     The XmlTextconstructor creates a text node with the
     string argument.

     Methods

     noneset‐xval‐>
     The set‐xvalmethod sets the text node value.

     Stringget‐xval‐>
     The get‐xvalmethod returns the text node value.

     Stringto‐normal‐>
     The to‐normalmethod returns the normalized text node
     value.

     XmlData
The XmlDataclass is the xml CDATA node. A data node differs
from the text node in the sense that the data node contains
characters that could be reserved characters such like
markup delimiters. The data node is most of the time used to
hold text used for scripting. The data node is an empty
node.

     Predicate

     data‐p

     Inheritance

     XmlNode

     Constructors

     XmlData(none)
     The XmlDataconstructor creates a default data node. By
     definition, a data node is an empty node.









                            ‐14‐


     XmlData(String)
     The XmlDataconstructor creates a data node with the
     string argument.

     Methods

     noneset‐xval‐>
     The set‐xvalmethod sets the data node value.

     Stringget‐xval‐>
     The get‐xvalmethod returns the data node value.

     XmlComment
The XmlCommentclass is the xml comment node. The comment
node is a special node that holds the comment text. The
comment node is an empty node.

     Predicate

     comment‐p

     Inheritance

     XmlNode

     Constructors

     XmlComment(none)
     The XmlCommentconstructor creates a default comment
     node. By definition, a comment node is an empty node.

     XmlComment(String)
     The XmlCommentconstructor creates a comment node with
     the string argument.

     Methods

     noneset‐xval‐>
     The set‐xvalmethod sets the comment node value.

     Stringget‐xval‐>
     The get‐xvalmethod returns the comment node value.

     XmlDoctype
The XmlDoctypeclass is the xml document type node. In its
simplest form, the document type has just a name which acts
the starting tag for the document. The document type can
also be associated with a system or a public identifier.
Note also that a local root node can be attached to this
node.

     Predicate

     doctype‐p









                            ‐15‐


     Inheritance

     XmlNode

     Constructors

     XmlDoctype(String)
     The XmlDoctypeconstructor creates a document type with
     a starting tag name as the string argument. This is the
     simplest form of a document type definition.

     String)XmlDoctype(String
     The XmlDoctypeconstructor creates a document type with
     a starting tag name and a system identifier. The first
     string argument is the tag name. The second argument is
     the system identifier.

     StringXmlDoctype(String
     The XmlDoctypeconstructor creates a document type with
     a starting tag name, a public and a system identifier.
     The first string argument is the tag name. The second
     argument is the public identifier. The third argument
     is the system identifier.

     Methods

     Stringget‐xval‐>
     The get‐xvalmethod returns the document type starting
     tag name.

     Stringget‐public‐id‐>
     The get‐public‐idmethod returns the document type
     public identifier.

     Stringget‐system‐id‐>
     The get‐system‐idmethod returns the document type
     system identifier.

     XmlPi
The XmlPiclass is the xml processing node. The processing
node is a tag node. Although a processing node is seen as
tag with attributes, the specification describes the
processing node as a special tag with a string value. The
processing node is an empty node.

     Predicate

     pi‐p

     Inheritance

     XmlNode











                            ‐16‐


     Constructors

     XmlPi(String)
     The XmlPiconstructor creates a processing node with the
     name string argument.

     String)XmlPi(String
     The XmlPiconstructor creates a processing node with the
     name string argument and the string value. The first
     argument is the tag name. The second argument is the
     processing node value.

     Methods

     noneset‐name‐>
     The set‐namemethod sets the xml pi node name.

     Stringget‐name‐>
     The get‐namemethod returns the pi node name.

     noneset‐xval‐>
     The set‐xvalmethod sets the processing node value.

     Stringget‐xval‐>
     The get‐xvalmethod returns the processing node value.

     Plistmap‐xval‐>
     The map‐xvalmethod map the processing node value to a
     property list.

     XmlDecl
The XmlDeclclass is the xml declaration node. The
declaration node is a processing node. A declaration node is
defined with a version id, an encoding string and a
standalone flag. Each value is represented by an attribute
at the tag level.

     Predicate

     decl‐p

     Inheritance

     XmlPi

     Constructors

     XmlDecl(none)
     The XmlDeclconstructor creates a default declaration
     node. By default, the declaration node is set with the
     xml version 1.0, the UTF‐8 encoding and the standalone
     flag is not set.

     XmlDecl(String)









                            ‐17‐


     The XmlDeclconstructor creates a declaration node with
     a version. The string argument is the xml version
     version which must be a supported one.

     String)XmlDecl(String
     The XmlDeclconstructor creates a declaration node with
     a version and an encoding. The string argument is the
     xml version version which must be a supported one. The
     second argument is the xml encoding.

     StringXmlDecl(String
     The XmlDeclconstructor creates a declaration node with
     a version, an encoding and a standalone flag. The
     string argument is the xml version version which must
     be a supported one. The second argument is the xml
     encoding. The third argument is the standalone flag.

     XmlRef
The XmlRefclass is the xml reference node class. This class
is a base class which cannot be instantiated directly. The
class is designed to hold reference, the only element which
is in common is the string representation.

     Predicate

     ref‐p

     Inheritance

     XmlNode

     Methods

     noneset‐xref‐>
     The set‐xrefmethod sets the node reference name.

     Stringget‐xref‐>
     The get‐xrefmethod returns the node reference name.

     XmlCref
The XmlCrefclass is the xml character reference node class.
Normally this class should only be used when building a xml
tree manually. During a parsing process, the character
reference is automatically expanded.

     Predicate

     cref‐p

     Inheritance

     XmlRef











                            ‐18‐


     Constructors

     XmlCref(none)
     The XmlCrefconstructor creates a default character
     reference those value is the null character.

     XmlCref(Character|Integer)
     The XmlCrefconstructor creates a character reference
     those value is the character or integer argument.

     Methods

     noneset‐value‐>
     The set‐valuemethod sets the character reference value
     by character or integer.

     Characterget‐value‐>
     The get‐valuemethod returns the character reference
     value.

     XmlEref
The XmlErefclass is the xml entity reference node class. The
entity reference is defined with a reference name.

     Predicate

     eref‐p

     Inheritance

     XmlRef

     Constructors

     XmlEref(none)
     The XmlCrefconstructor creates an empty entity
     reference.

     XmlCref(String)
     The XmlErefconstructor creates an entity reference
     those value is the string argument.

     XmlSection
The XmlSectionclass is the xml section type node. A section
node is used to model conditional section that are part of a
DTD. The section value is a string that is evaluated by the
xml processor. Most of the time, it is a parameter entity
reference which corresponds to the keyword INCLUDE or IGNORE
, but it could be anything else. A node is also attached to
this section.

     Predicate

     section‐p









                            ‐19‐


     Inheritance

     xmlNode

     Constructors

     XmlSection(String)
     The XmlSectionconstructor creates a xml section node by
     value.

     Methods

     Stringget‐xval‐>
     The get‐xvalmethod returns the section node value.

     XmlAttlist
The XmlAttlistclass is the xml attribute list node class. A
xml attribute list is primarily defined with two names. The
first name is the element and the second name is the
attribute name. There are 3 types of attribute list. The
string type, the token type and the enumeration type. The
class manages each type by associating a type descriptor
which is detected at construction.

     Predicate

     attlist‐p

     Inheritance

     XmlNode

     Constructors

     String)XmlAttlist(String
     The XmlAttlistconstructor creates an attribute list by
     element name and attribute name. The first argument is
     the element name. The second argument is the attribute
     name.

     Methods

     noneset‐element‐name‐>
     The set‐element‐namemethod sets the attribute list
     element name.

     Stringget‐element‐name‐>
     The get‐element‐namemethod returns the attribute list
     element name.

     noneset‐attribute‐name‐>
     The set‐attribute‐namemethod sets the attribute list
     name.










                            ‐20‐


     Stringget‐attribute‐name‐>
     The get‐attribute‐namemethod returns the attribute list
     name.

     noneset‐type‐>
     The set‐typemethod set the attribute type by string or
     enumeration vector. In its first form, the attribute
     type is defined by a string. The type can be either,
     "CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES",
     "NMTOKEN" or "NMTOKENS". In the second form, the
     attribute type is an enumeration those values are
     defined in the argument vector. The boolean argument
     controls the notation flag for that enumeration.

     noneset‐default‐>
     The set‐defaultmethod set the attribute value by
     string. The string can be any value or the special
     value "#IMPLIED" and "#REQUIRED". If the default value
     is fixed, the set‐fixedis the preferred method.

     noneset‐fixed‐>
     The set‐fixedmethod set the fixed attribute default
     value by string.

     XmlRoot
The XmlRootclass is the top level root instantiated by the
xml reader when starting to parse a stream. There should be
only one root node in a tree. The root node does not have a
parent node.

     Predicate

     root‐p

     Inheritance

     XmlNode

     Constructors

     XmlRoot(none)
     The XmlRootconstructor creates a default xml root node
     which is empty.

     Methods

     XmlBodydup‐body‐>
     The dup‐bodymethod duplicates the root node by
     duplicating the root body without the declaration node.

     Booleandeclaration‐p‐>
     The declaration‐ppredicate returns true if a
     declaration node exists in the root node.










                            ‐21‐


     XmlDeclget‐declaration‐>
     The get‐declarationmethod returns the declaration node
     associated with the root node. Normally, the
     declaration node is the first child node. If the
     declaration node does not exist, an exception is
     raised.

     Stringget‐encoding‐>
     The get‐encodingmethod returns the root encoding mode.
     The root encoding mode is extracted from the
     declaration node, if such node exists, or the default
     xml system encoding is returned.

     XmlDocument
The XmlDocumentclass is the xml document class. The document
class is the root document class that maintains a xml
document along with its associated tree and other useful
information. Generally the class is constructed with a file
name or a name and an input stream that is used for parsing
the input data. The document can also be designed by
constructing manually the document tree. In that case, the
document name must be set explicitly.

     Predicate

     document‐p

     Inheritance

     Nameable

     Constructors

     XmlDocument(none)
     The XmlDocumentconstructor creates a default xml
     document.

     XmlDocument(String)
     The XmlDocumentconstructor creates a xml document by
     parsing the file. The file name is the string argument.

     InputStream)XmlDocument(String
     The XmlDocumentconstructor creates a xml document by
     name and by parsing the input stream. The first
     argument is the xml document name. The second argument
     is the input stream to parse.

     XmlRoot)XmlDocument(String
     The XmlDocumentconstructor creates a xml document by
     name and root node. The first argument is the xml
     document name. The second argument is the xml root
     node.











                            ‐22‐


     Methods

     noneset‐name‐>
     The set‐namemethod sets the xml document name. The get‐
     namemethod is available from the nameablebase class.

     XmlRootget‐root‐>
     The get‐rootmethod returns the document xml root node.

     XmlRootget‐body‐>
     The get‐bodymethod returns the document xml root node
     body without the declaration node.

     XmlElement
The XmlElementclass is the xml element class node. A xml
element is represented with a name and a value. It is during
the processing phase that the element value is interpreted.
An element is built with a name and a value.

     Predicate

     element‐p

     Inheritance

     XmlNode

     Constructors

     String)XmlElement(String
     The XmlElementconstructor creates a xml element by name
     and value. The first argument is the element name. The
     second argument is the argument value.

     Methods

     noneset‐name‐>
     The set‐namemethod sets the xml element name.

     Stringget‐name‐>
     The get‐namemethod returns the element name.

     noneset‐xval‐>
     The set‐xvalmethod sets the xml element value.

     Stringget‐xval‐>
     The get‐xvalmethod returns the element value.

     XmlEntity
The XmlEntityclass is the base class for the xml entity
representation. A xml entity can be either a general entity
or a parameter entity. They differ initially with the
presence of the ’%’ character. Both entity model have a name
which is path of the base class.









                            ‐23‐


     Predicate

     entity‐p

     Inheritance

     XmlNode

     Methods

     noneset‐name‐>
     The set‐namemethod sets the entity name.

     Stringget‐name‐>
     The get‐namemethod returns the entity name.

     XmlGe
The XmlGeclass is the xml general entity node. In its
simplest form, the general entity has a name and a value.
The entity type can also be associated with a system or a
public identifier with or without an extra type name.

     Predicate

     ge‐p

     Inheritance

     XmlEntity

     Constructors

     String)XmlGe(String
     The XmlGeconstructor creates a xml entity by name and
     value. The first argument is the entity name. The
     second argument is the entity value. Most of the time,
     the entity value is a parameter entity.

     StringXmlGe(String
     The XmlGeconstructor creates a xml entity by name and
     identifier. The first argument is the entity name. The
     second argument is the entity public identifier. The
     third argument is the entity system identifier.

     StringXmlGe(String
     The XmlGeconstructor creates a xml entity by name,
     identifier and data type. The first argument is the
     entity name. The second argument is the entity public
     identifier. the third argument is the entity system
     identifier. The fourth argument is the entity type
     name.

     Methods










                            ‐24‐


     Stringget‐xval‐>
     The get‐xvalmethod returns the entity value.

     Stringget‐data‐>
     The get‐datamethod returns the entity data type.

     Stringget‐public‐id‐>
     The get‐public‐idmethod returns the entity public
     identifier.

     Stringget‐system‐id‐>
     The get‐system‐idmethod returns the entity system
     identifier.

     XmlPe
The XmlPeclass is the xml parameter entity node. In its
simplest form, the parameter entity has a name and a value.
The entity type can also be associated with a system or a
public identifier.

     Predicate

     ge‐p

     Inheritance

     XmlEntity

     Constructors

     String)XmlPe(String
     The XmlGeconstructor creates a xml entity by name and
     value. The first argument is the entity name. The
     second argument is the entity value.

     StringXmlPe(String
     The XmlGeconstructor creates a xml entity by name and
     identifier. The first argument is the entity name. The
     second argument is the entity public identifier. The
     third argument is the entity system identifier.

     Methods

     Stringget‐xval‐>
     The get‐xvalmethod returns the entity value.

     Stringget‐public‐id‐>
     The get‐public‐idmethod returns the entity public
     identifier.

     Stringget‐system‐id‐>
     The get‐system‐idmethod returns the entity system
     identifier.










                            ‐25‐


     XmlReader
The XmlReaderclass is the xml parser that operates on an
input stream. The reader creates a tree of nodes by reading
the input stream and returns the root node when an end‐of‐
stream is reached. Multiple read can be done sequentially.
If the reset method is not called between multiple read
passes, the reader will accumulate the nodes in the current
tree.

     Predicate

     reader‐p

     Inheritance

     Object

     Constructors

     XmlReader(none)
     The XmlReaderconstructor creates a default xml reader.

     Methods

     nonereset‐>
     The resetmethod resets the xml reader. In particular,
     the root node is restored to the nil node.

     noneparse‐>
     The parsemethod parses an input stream or a file.
     During the parsing process, the root node is filled
     with the parsed nodes.

     XmlRootget‐root‐>
     The get‐rootmethod returns the parsed root node.

     XmlNodeget‐node‐>
     The get‐nodemethod parse a string and returns a node.

     Xne
The Xneis a nameset that binds constants used by the xne
system.

     Constants

     ID
     The IDconstant defines a node access by id.

     PI
     The PIconstant defines an access selector for a
     processing instruction node.

     GE
     The GEconstant defines an access selector for a general









                            ‐26‐


     entity node.

     TAG
     The TAGconstant defines an access selector for a tag
     node.

     ENT
     The ENTconstant defines an access selector for an
     entity node.

     EREF
     The EREFconstant defines an access selector for an
     entity reference node.

     CREF
     The CREFconstant defines an access selector for an
     character reference node.

     ELEM
     The ELEMconstant defines an access selector for an
     element node.

     TEXT
     The TEXTconstant defines an access selector for a text
     node.

     NAME
     The NAMEconstant defines a node access by name.

     CDATA
     The CDATAconstant defines an access selector for a
     character data node.

     INDEX
     The INDEXconstant defines a node access by child index.
     The child index is node index seen from the parent.

     XneTree
The XneTreeis the xne node tree manipulation class. The
class operates with a node and provides numerous methods to
manipulate the tree as well as changing it. Before a tree is
manipulated, it is recommended to make a copy of such tree
with the help of the node copymethod.

     Predicate

     xne‐tree‐p

     Inheritance

     Object

     Constructors










                            ‐27‐


     XmlTree(none)
     The XmlTreeconstructor creates a default tree without a
     node.

     XmlTree(XmlNode)
     The XmlTreeconstructor creates a tree with a xml node.
     The node stored in the object is the root of the tree
     subject to the operations.

     Methods

     Integerdepth‐>
     The depthmethod returns the depth of the tree.

     Integergenerate‐id‐>
     The generate‐idmethod generate a unique id for all node
     in the tree. The id attribute is set by this method.

     noneset‐node‐>
     The set‐nodemethod sets the root tree node.

     XmlNodeget‐node‐>
     The get‐nodemethod returns the root tree node.

     noneset‐attribute‐>
     The set‐attributemethod sets an attribute to the whole
     tree. In the first form, the attribute is set to the
     whole tree. In the second form with a string argument,
     the attribute is set only on the tag node those name
     matches the name argument.

     noneclear‐attribute‐>
     The clear‐attributemethod clear all attributes of the
     nodes in the tree. In the first form, the node
     attributes are cleared for all nodes in the tree. In
     the second form with a string argument, the attributes
     are cleared only with the tag node those name matches
     the name argument.

     noneset‐prefix‐>
     The set‐prefixmethod sets a prefix on all nodes in the
     tree.

     noneclear‐prefix‐>
     The clear‐prefixmethod clear the prefix for all nodes
     in the tree.

     Vectorselect‐>
     The selectmethod selects the node in the tree that
     matches the condition argument. In the first form, with
     one argument, the whole tree is searched. In the second
     form, with a boolean argument, the whole tree is
     searched if the second argument is false. If the
     boolean argument is true, the method call behaves like









                            ‐28‐


     a call with the condition only.

     XneChild
The XneCondis the xne condition class. The sole purpose of
this class is to define one or several condition that a node
must satisfy in order to be selected. The condition are
accumulated in a list and later checked for a particular
node. Note that an empty condition always succeeds.

     Predicate

     xne‐cond‐p

     Inheritance

     Object

     Constructors

     XneCond(none)
     The XneCondconstructor creates a default condition. The
     default condition is empty. The empty condition always
     succeeds.

     Methods

     noneadd‐>
     The addadds a condition by type. The first argument is
     the condition type. The second argument is a condition
     information such like a string or an integer.

     Booleanvalid‐p‐>
     The valid‐ppredicate checks that a node matches a
     condition. If the condition succeeds, the predicate
     returns true.

     XsmNode
The XsmNodeis a base class which is part of the xml simple
model (xsm). In this model, a xml (or sgml, or html) text is
represented by a node which can be either a tag, a text or a
reference node. There is no concept of tree. The node
content is stored in the form of a text string. This simple
model is designed to parse weak data representation such
like html text and later process it at the user discretion.
The default representation is an empty text node.

     Predicate

     xsm‐node‐p

     Inheritance

     Object










                            ‐29‐


     Constants

     TXT
     The TXTconstant defines a xsm text node.

     TAG
     The TAGconstant defines a xsm tag node.

     REF
     The REFconstant defines a xsm reference node.

     END
     The ENDconstant defines a xsm end node.

     Constructors

     XsmNode(none)
     The XsmNodeconstructor creates a default xsm node which
     is an empty text node.

     XsmNode(String)
     The XsmNodeconstructor creates a xsm text node by
     value. The string argument is the text node value

     String)XsmNode(Item
     The XsmNodeconstructor creates a xsm text node by type
     and value. The first argument is the node type. The
     second argument is the node text value.

     Methods

     Booleantext‐p‐>
     The text‐ppredicate returns true if the node is a text
     node.

     Booleantag‐p‐>
     The tag‐ppredicate returns true if the node is a tag
     node.

     Booleanref‐p‐>
     The reference‐ppredicate returns true if the node is a
     reference node.

     Booleanend‐p‐>
     The end‐ppredicate returns true if the node is a
     reference node.

     Booleannormal‐p‐>
     The normal‐ppredicate returns true if the node is a
     normal tag node.

     Booleanreserved‐p‐>
     The reserved‐ppredicate returns true if the node is a
     reserved tag node.









                            ‐30‐


     Booleantextable‐p‐>
     The textable‐ppredicate returns true if the node is a
     textable node, that is a text node or a reference node.

     Integerget‐source‐line‐>
     The get‐source‐linemethod returns the node source line
     number if any.

     noneset‐source‐line‐>
     The set‐source‐linemethod sets the node source line
     number.

     Stringget‐source‐name‐>
     The get‐source‐namemethod returns the node source name
     if any.

     noneset‐source‐name‐>
     The set‐source‐namemethod sets the node source name.

     Stringget‐name‐>
     The get‐namemethod returns the next available name.
     name.

     XsmReader
The XmlReaderclass is the simple model node reader. The
reader operates with the parsemethod and returns a node or
nil if the end of stream is reached. Unlike the xml reader,
this reader does not build a tree and the node content is
not even parsed. In this model, the node content is to be
interpreted at the user discretion.

     Predicate

     xsm‐reader‐p

     Inheritance

     Object

     Constructors

     XsmReader(none)
     The XsmReaderconstructor creates a default xsm reader.
     The reader is not bound to any stream.

     XsmReader(InputStream)
     The XsmReaderconstructor creates a xsm reader with an
     input stream. The argument is the input bound to the
     reader.

     XsmReader(String)
     The XsmReaderconstructor creates a xsm reader with an
     input string stream. The argument is a string which is
     used to create an input string stream bound to the









                            ‐31‐


     reader.

     Methods

     noneset‐input‐stream‐>
     The set‐input‐streammethod bind a new input stream to
     the reader. Subsequent read will use the newly bound
     stream

     XsmNodeget‐node‐>
     The get‐nodemethod parses the input stream and returns
     the available node.

     XsmDocument
The XsmDocumentclass is the document class that maintains a
xsm document along with its associated list of nodes and
other useful information. Generally the class is constructed
with a file name or a name and an input stream that is used
for parsing the input data. When the input stream has been
parsed, the nodes are stored in a vector which can be access
by index.

     Predicate

     document‐p

     Inheritance

     Nameable

     Constructors

     XsmDocument(none)
     The XsmDocumentconstructor creates a default xsm
     document.

     XsmDocument(String)
     The XsmDocumentconstructor creates a xsm document by
     name. The string argument is the file name to parse.

     InputStream)XsmDocument(String
     The XsmDocumentconstructor creates a xsm document by
     name and by parsing the input stream. The first
     argument is the xsm document name. The second argument
     is the input stream to parse.

     Methods

     noneset‐name‐>
     The set‐namemethod sets the xsm document name. The get‐
     namemethod is available from the nameablebase class.

     Integerlength‐>
     The lengthmethod returns the xsm document length. The









                            ‐32‐


     document length is the number of nodes parsed and
     stored in the document.

     XsmNodeget‐node‐>
     The get‐nodemethod returns a document node by index.

     XsoInfoget‐info‐>
     The get‐infomethod returns a node info object by index.
     The info object is evaluated dynamically from the
     document node. In the first form, the node name is used
     to find the node end tag in order to construct the info
     text value. In the second form, the boolean argument,
     if true, forces the node name to be converted to lower
     case prior any comparison.

     XsoInfoget‐info‐vector‐>
     The get‐info‐vetcormethod returns an info object vector
     by name. Each info object have their name that matches
     the string argument. The info object is evaluated
     dynamically from the document node. In the first form,
     the node name is used to match a tag node and then find
     the node end tag in order to construct the info text
     value. In the second form, the boolean argument, if
     true, forces the node name to be converted to lower
     case prior any comparison.

     XsoInfo
The XsoInfoclass is a xml/xsm information node used to carry
simple information about a tag. The node is constructed by
name, with a set of attributes and eventually a text
associated with the node. The text information is generally
the one associated between the start tag and the end tag. In
the case of complex tree, such text data might be empty.

     Predicate

     xso‐info‐p

     Inheritance

     Nameable

     Constructors

     XsoInfo(none)
     The XsoInfoconstructor creates a default info object.

     XsoInfo(String)
     The XsoInfoconstructor creates an info object by name.
     The string argument is the node info name.

     String)XsoInfo(String
     The XsoInfoconstructor creates an info object by name
     and text. The first argument is the node info name. The









                            ‐33‐


     second argument is the node text information.

     Methods

     noneset‐name‐>
     The set‐namemethod sets the info object name.

     noneset‐attribute‐>
     The set‐attributemethod sets an attribute by name and
     value. The first argument is the attribute name. The
     second argument is the attribute value.

     Plistget‐attribute‐list‐>
     The get‐attribute‐listmethod returns the node attribute
     list in the form of a property list object.

     Stringget‐attribute‐value‐>
     The get‐attribute‐valuemethod returns the attribute
     value by name. The string argument is the attribute
     name.

     noneset‐text‐>
     The set‐textmethod sets the info object text.

     Stringget‐text‐>
     The get‐textmethod returns the text information.