'\" t .\" This documentation, which is part of the afnix writing .\" system distribution, is free and can be distributed as .\" long as this copyright notice is left intact. .\" .\" This documentation is distributed in the hope that it .\" will be useful, but without any warranty; without even .\" the implied warranty of merchantability and fitness .\" for a particular purpose. In no event, shall the .\" copyright holder be liable for any direct, incident .\" incidental or special damages arising in any way out .\" of the use of this documentation. .\" .\" Copyright (c) 1999-2020 Amaury Darsch .\" .TH xml 3 2020-12-26 AFNIX "AFNIX Module" .SH NAME xml - standard xml module .SH STANDARD XML MODULE The Standard XML module 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 model which enable the quick parsing of documents with a relaxed rule checking approach. .PP .B XML tree representation .br A xml document is represented with a tree. At the top of the tree is the XmlRoot object. 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 XmlNode objects. .PP .I Node base object .br The xml tree is built with the XmlNode object. The node object has different derivation depending on the required representation. For example, the XmlRoot object is derived from the XmlNode object. 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
xhtml empty tag or an empty paragraph

. Although a xml node cannot be constructed directly, there is a predicate node-p that can be used to assert the node type. .sp .nf # check a node assert true (afnix:xml:node-p node) .fi .sp The add-child method 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 parse method should be used. .sp .nf # parse a text and add 3 child nodes p:parse "The quick brown fox jumps over the lazy dog" .fi .sp In the previous example, the first child node is a XmlText node with the value The quick brown . The second node is a XmlTag node with name b. Finally, the third node is also a XmlText node with the value jumps over the lazy dog. It should be noted that the tag node has a child XmlText node with the value fox. This example also illustrates the power of the parse method 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 reference with the parse method. 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 XmlCref is provided in the module. .PP .I Tag object .br The XmlTag class 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. .sp .nf # create an empty paragraph tag const p (afnix:xml:XmlTag "p" true) .fi .sp Adding attributes to a tag is imply a matter of method call. The add-attribute method operates with a Property object while the set-attribute operates with a name and a literal value. As a matter of fact, the attributes are stored internally as a property list. .sp .nf #

# create a paragraph tag const p (afnix:xml:XmlTag "p") # set the class attribute p:set-attribute "class" "text" .fi .sp 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. .sp .nf #
# create a br empty tag const br (afnix:xml:XmlTag "br" true) .fi .sp .PP .I Text objects .br The xml module provides two types of xml text node. The basic object is the XmlText node which is designed to hold some text without markup. It is this kind of nodes which is automatically instantiated by the parse method, as described earlier. The other object is the XmlData which corresponds to the xml CDATA special markup. With a character data node, the characters are not interpreted, including those that indicate markup starts like < or end like >. The XmlData is particularly used to store scripts or other program text inside a xml description. As an example, it is recommended to use a character data node inside a script tag with xhtml. .PP .B Document reading .br A xml document is read by scanning an input stream an building a representation of the xml tree. .PP .I The document object .br The XmlDocument object 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. .sp .nf # create a xml document const xdoc (afnix:xml:XmlDocument "example.xml") # get the root node const rppt (xdoc:get-root) .fi .sp .PP .I The root node content .br 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. .PP .B Node tree operations .br The class XneTree provides a single framework to operate on a node and its associated tree. Since a node always carries a sub-tree, the node tree term will be used to reference it. .PP .I Creating a node tree .br A node tree is created either from a node at construction or with the help of the set-node method. .sp .nf # create a node tree at construction const tree (afnix:xml:XneTree root) # change the node tree tree:set-node node .fi .sp Once a tree is created, various methods are provided to operate on the whole tree. The depth method returns the depth of the node tree. The get-node methods returns the the node associated with the tree. .sp .nf # get the tree depth println (tree:depth) .fi .sp .PP .I Namespace operations .br The concept of namespace is 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 without too much burden. In the xml namespace terminology, an expanded name is composed of a prefix and a local name. The basic operations provided at the tree level is the prefix cancellation and the tree prefix setting. .sp .nf # clear the prefix for the whole tree tree:clear-prefix # set a prefix for the whole tree tree:set-prefix "afnix" .fi .sp The set-prefix changes the prefix for the whole tree. It is not necessary to clear first the prefix. .PP .I Attribute operations .br 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-attribute method of the XmlTag is the definitive answer. .sp .nf # clear all attributes tree:clear-attribute # clear all attributes by tag name tree:clear-attribute "p" .fi .sp The set-attribute method 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-attribute method can be also called at the tag level. .sp .nf # clear all attributes tree:set-attribute "class" "text" .fi .sp 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-id generates 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. .sp .nf # set a unique id for all nodes tree:generate-id .fi .sp .PP .B Node location and searching .br 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 XmlTag node, although it might not be always the case. .PP .I Node selection .br The process of finding a child node is obtained with the help of the XneCond class combined with the select method of the XneTree Object. The select method 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. .sp .nf # 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) .fi .sp 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. .PP .I Node condition .br The XmlCond class provides several method to add a conditions. The add method 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. .sp .nf # creating a condition node const xcnd (afnix:xml:XneCond) # add a condition by name xcnd:add afnix:xml:xne:NAME "p" .fi .sp In the previous example, a condition is designed to operate with a tag name. Upon a call to the select method with this condition, all nodes in the tree that have the tag name p will be selected. .sp .nf # 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 .fi .sp In the previous example, a condition is designed to operate with a tag name and index. Upon a call to the select method with this condition, all nodes in the tree that have the tag name p and those child index is 0 will be selected. .PP .I Selection result .br The node selection operates by default on the whole tree. The select method, when called with a second boolean argument can restrict the search to the child nodes. .sp .nf # 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) .fi .sp The selection results is stored in a vector object. The node order corresponds to the tree order obtained with a depth first search approach. .PP .B Simple model node .br 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 XsmNode is 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. .PP .I Creating a node .br 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. .sp .nf # 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"> .fi .sp 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. .sp .nf # create a reserved tag const rtag ( afnix:xml:XsmNode afnix:xml:XsmNode:TAG "!-- example --") .fi .sp .PP .I Node representation .br The xsm node is a literal node. This means that the to-string and to-literal methods are available. When the to-literal method is called, the node text is automatically formatted to reflect the node type. .sp .nf # create a reserved tag const rtag ( afnix:xml:XsmNode afnix:xml:XsmNode:TAG "!-- example --") # print the node literal rtag:to-literal # .fi .sp If the node is a reference node, the node literal is represented with the original definition while the to-string method will produce the corresponding character if it known. .PP .I Node information .br With a xsm node, the operation are a limited number of node information operations. The get-name method returns the first name found in a node. If the node is a normal tag, the get-name will 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. .sp .nf # create a tag node const ntag ( afnix:xml:XsmNode afnix:xml:XsmNode:TAG "afnix"> # get the tag name ntag:get-name .fi .sp There is a predicate for all types. For example, the text-p predicate returns true if the node is a text node. The tag-p predicate returns true if the node is a normal or reserved tag. .PP .B Document reading .br A document is read in a way similar to the XmlDocument with the help of the XsmDocument object. Once created, the document holds a vector of nodes. .PP .I The document object .br The XsmDocument object 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. .sp .nf # create a xms document const xdoc (afnix:xml:XsmDocument "example.htm") # get the document length xdoc:length .fi .sp .PP .I Node information object .br The XsoInfo object 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. .sp .nf # create a xso node by name and text const info (afnix:xml:XsoInfo "a" "click here") .fi .sp .PP .I Simple model operations .br The XsmDocument is 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 information is returned instead of a vector of nodes which can always be constructed with a simple loop. .sp .nf # 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 .fi .sp .SH STANDARD XML REFERENCE .PP .B XmlNode .br The XmlNode class 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. .PP .I Predicate .br .sp .RS node-p .RE .PP .I Inheritance .br .sp .RS Object .RE .PP .I Methods .br .sp .RS .B to-text -> String (none) .br The to-text method returns a text representation of the 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. .RE .sp .RS .B write -> none (none|OutputStream|Buffer) .br The write method 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. .RE .sp .RS .B name-p -> Boolean (String) .br The name-p predicate 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. .RE .sp .RS .B attribute-p -> Boolean (String| String String) .br The attribute-p predicate 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. .RE .sp .RS .B parse -> none (String) .br The parse method 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. .RE .sp .RS .B get-parent -> XmlNode (none) .br The get-parent method returns the parent node. If the node is the root node, nil is returned. .RE .sp .RS .B set-parent -> none (XmlNode) .br The set-parent method sets the parent node. .RE .sp .RS .B copy -> XmlNode (none) .br The copy method copy the node tree by regenerating a new tree. .RE .sp .RS .B del-child -> none (Integer | String | String String | String String String) .br The del-child method 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, 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. .RE .sp .RS .B del-attribute-child -> none (String | String String) .br The del-attribute-child method 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. .RE .sp .RS .B clear-child -> none (none) .br The clear-child method clear the child node list, leaving the node without child node. .RE .sp .RS .B add-child -> none (XmlNode|XmlNode Integer) .br The add-child method 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. .RE .sp .RS .B get-child -> XmlNode (Integer String) .br The get-child method 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. .RE .sp .RS .B get-index -> Integer (XmlNode) .br The gett-index method 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. .RE .sp .RS .B merge -> none (XmlNode Integer) .br The merge method 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. .RE .sp .RS .B nil-child-p -> Boolean (none) .br The nil-child-p predicate returns true if the node does not have a child node. .RE .sp .RS .B child-p -> Boolean (String | String String | String String String) .br The child-p predicate 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. .RE .sp .RS .B attribute-child-p -> Boolean (String String | String String String) .br The attribute-child-p predicate 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. .RE .sp .RS .B lookup-child -> XmlNode (String) .br The lookup-child method returns a child node by name. Unlike the get-child method, the method raises an exception if the node cannot be found. .RE .sp .RS .B child-length -> Integer (none|String) .br The child-length method 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. .RE .sp .RS .B get-source-line -> Integer (none) .br The get-source-line method returns the node source line number if any. .RE .sp .RS .B set-source-line -> none (Integer) .br The set-source-line method sets the node source line number. .RE .sp .RS .B get-source-name -> String (none) .br The get-source-name method returns the node source name if any. .RE .sp .RS .B set-source-name -> none (String) .br The set-source-name method sets the node source name. .RE .PP .B XmlTag .br The XmlTag class 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. .PP .I Predicate .br .sp .RS tag-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Constructors .br .sp .RS .B XmlTag (String) .br The XmlTag constructor creates a tag node. The node is not marked empty. .RE .sp .RS .B XmlTag (String Boolean) .br The XmlTag constructor creates a tag node. The first argument is the tag name. The second argument is the empty flag. .RE .PP .I Methods .br .sp .RS .B set-name -> none (String) .br The set-name method sets the tag name. .RE .sp .RS .B get-name -> String (none) .br The get-name method returns the tag name. .RE .sp .RS .B clear-attribute -> none (node) .br The clear-attribute method clear the node attribute list. .RE .sp .RS .B add-attribute -> none (Property) .br The add-attribute method adds a new attribute to the tag. The attribute must be new for this method to succeed. In doubt, the set-attribute is preferable. .RE .sp .RS .B set-attribute -> none (String Literal) .br The set-attribute method 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. .RE .sp .RS .B get-attribute -> Property (Integer|String) .br The get-attribute method 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. .RE .sp .RS .B get-attribute-value -> String (String) .br The get-attribute-value method returns a tag attribute value by name. The string argument is the attribute name. If the property is not found, an exception is raised. .RE .sp .RS .B lookup-attribute -> Property (String) .br The lookup-attribute method 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. .RE .sp .RS .B attribute-length -> Integer (none) .br The attribute-length method returns the number of attributes. .RE .PP .B XmlText .br The XmlText class is the xml text node. A text node is directly built by the xml reader and the content placed into a string. By definition, a text node is an empty node. .PP .I Predicate .br .sp .RS text-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Constructors .br .sp .RS .B XmlText (none) .br The XmlText constructor creates a default text node. By definition, a text node is an empty node. .RE .sp .RS .B XmlText (String) .br The XmlText constructor creates a text node with the string argument. .RE .PP .I Methods .br .sp .RS .B set-xval -> none (String) .br The set-xval method sets the text node value. .RE .sp .RS .B get-xval -> String (none) .br The get-xval method returns the text node value. .RE .sp .RS .B to-normal -> String (none) .br The to-normal method returns the normalized text node value. .RE .PP .B XmlData .br The XmlData class 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. .PP .I Predicate .br .sp .RS data-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Constructors .br .sp .RS .B XmlData (none) .br The XmlData constructor creates a default data node. By definition, a data node is an empty node. .RE .sp .RS .B XmlData (String) .br The XmlData constructor creates a data node with the string argument. .RE .PP .I Methods .br .sp .RS .B set-xval -> none (String) .br The set-xval method sets the data node value. .RE .sp .RS .B get-xval -> String (none) .br The get-xval method returns the data node value. .RE .PP .B XmlComment .br The XmlComment class is the xml comment node. The comment node is a special node that holds the comment text. The comment node is an empty node. .PP .I Predicate .br .sp .RS comment-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Constructors .br .sp .RS .B XmlComment (none) .br The XmlComment constructor creates a default comment node. By definition, a comment node is an empty node. .RE .sp .RS .B XmlComment (String) .br The XmlComment constructor creates a comment node with the string argument. .RE .PP .I Methods .br .sp .RS .B set-xval -> none (String) .br The set-xval method sets the comment node value. .RE .sp .RS .B get-xval -> String (none) .br The get-xval method returns the comment node value. .RE .PP .B XmlDoctype .br The XmlDoctype class 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. .PP .I Predicate .br .sp .RS doctype-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Constructors .br .sp .RS .B XmlDoctype (String) .br The XmlDoctype constructor creates a document type with a starting tag name as the string argument. This is the simplest form of a document type definition. .RE .sp .RS .B XmlDoctype (String String) .br The XmlDoctype constructor 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. .RE .sp .RS .B XmlDoctype (String String String) .br The XmlDoctype constructor 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. .RE .PP .I Methods .br .sp .RS .B get-xval -> String (none) .br The get-xval method returns the document type starting tag name. .RE .sp .RS .B get-public-id -> String (none) .br The get-public-id method returns the document type public identifier. .RE .sp .RS .B get-system-id -> String (none) .br The get-system-id method returns the document type system identifier. .RE .PP .B XmlPi .br The XmlPi class 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. .PP .I Predicate .br .sp .RS pi-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Constructors .br .sp .RS .B XmlPi (String) .br The XmlPi constructor creates a processing node with the name string argument. .RE .sp .RS .B XmlPi (String String) .br The XmlPi constructor 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. .RE .PP .I Methods .br .sp .RS .B set-name -> none (String) .br The set-name method sets the xml pi node name. .RE .sp .RS .B get-name -> String (none) .br The get-name method returns the pi node name. .RE .sp .RS .B set-xval -> none (String) .br The set-xval method sets the processing node value. .RE .sp .RS .B get-xval -> String (none) .br The get-xval method returns the processing node value. .RE .sp .RS .B map-xval -> Plist (String) .br The map-xval method map the processing node value to a property list. .RE .PP .B XmlDecl .br The XmlDecl class 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. .PP .I Predicate .br .sp .RS decl-p .RE .PP .I Inheritance .br .sp .RS XmlPi .RE .PP .I Constructors .br .sp .RS .B XmlDecl (none) .br The XmlDecl constructor 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. .RE .sp .RS .B XmlDecl (String) .br The XmlDecl constructor creates a declaration node with a version. The string argument is the xml version version which must be a supported one. .RE .sp .RS .B XmlDecl (String String) .br The XmlDecl constructor 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. .RE .sp .RS .B XmlDecl (String String String) .br The XmlDecl constructor 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. .RE .PP .B XmlRef .br The XmlRef class 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. .PP .I Predicate .br .sp .RS ref-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Methods .br .sp .RS .B set-xref -> none (String) .br The set-xref method sets the node reference name. .RE .sp .RS .B get-xref -> String (none) .br The get-xref method returns the node reference name. .RE .PP .B XmlCref .br The XmlCref class 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. .PP .I Predicate .br .sp .RS cref-p .RE .PP .I Inheritance .br .sp .RS XmlRef .RE .PP .I Constructors .br .sp .RS .B XmlCref (none) .br The XmlCref constructor creates a default character reference those value is the null character. .RE .sp .RS .B XmlCref (Character|Integer) .br The XmlCref constructor creates a character reference those value is the character or integer argument. .RE .PP .I Methods .br .sp .RS .B set-value -> none (Character|Integer) .br The set-value method sets the character reference value by character or integer. .RE .sp .RS .B get-value -> Character (none) .br The get-value method returns the character reference value. .RE .PP .B XmlEref .br The XmlEref class is the xml entity reference node class. The entity reference is defined with a reference name. .PP .I Predicate .br .sp .RS eref-p .RE .PP .I Inheritance .br .sp .RS XmlRef .RE .PP .I Constructors .br .sp .RS .B XmlEref (none) .br The XmlCref constructor creates an empty entity reference. .RE .sp .RS .B XmlCref (String) .br The XmlEref constructor creates an entity reference those value is the string argument. .RE .PP .B XmlSection .br The XmlSection class 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. .PP .I Predicate .br .sp .RS section-p .RE .PP .I Inheritance .br .sp .RS xmlNode .RE .PP .I Constructors .br .sp .RS .B XmlSection (String) .br The XmlSection constructor creates a xml section node by value. .RE .PP .I Methods .br .sp .RS .B get-xval -> String (none) .br The get-xval method returns the section node value. .RE .PP .B XmlAttlist .br The XmlAttlist class 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. .PP .I Predicate .br .sp .RS attlist-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Constructors .br .sp .RS .B XmlAttlist (String String) .br The XmlAttlist constructor creates an attribute list by element name and attribute name. The first argument is the element name. The second argument is the attribute name. .RE .PP .I Methods .br .sp .RS .B set-element-name -> none (String) .br The set-element-name method sets the attribute list element name. .RE .sp .RS .B get-element-name -> String (none) .br The get-element-name method returns the attribute list element name. .RE .sp .RS .B set-attribute-name -> none (String) .br The set-attribute-name method sets the attribute list name. .RE .sp .RS .B get-attribute-name -> String (none) .br The get-attribute-name method returns the attribute list name. .RE .sp .RS .B set-type -> none (String | Vector Boolean) .br The set-type method 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. .RE .sp .RS .B set-default -> none (String) .br The set-default method 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-fixed is the preferred method. .RE .sp .RS .B set-fixed -> none (String) .br The set-fixed method set the fixed attribute default value by string. .RE .PP .B XmlRoot .br The XmlRoot class 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. .PP .I Predicate .br .sp .RS root-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Constructors .br .sp .RS .B XmlRoot (none) .br The XmlRoot constructor creates a default xml root node which is empty. .RE .PP .I Methods .br .sp .RS .B dup-body -> XmlBody (none) .br The dup-body method duplicates the root node by duplicating the root body without the declaration node. .RE .sp .RS .B declaration-p -> Boolean (none) .br The declaration-p predicate returns true if a declaration node exists in the root node. .RE .sp .RS .B get-declaration -> XmlDecl (none) .br The get-declaration method 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. .RE .sp .RS .B get-encoding -> String (none) .br The get-encoding method 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. .RE .PP .B XmlDocument .br The XmlDocument class 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. .PP .I Predicate .br .sp .RS document-p .RE .PP .I Inheritance .br .sp .RS Nameable .RE .PP .I Constructors .br .sp .RS .B XmlDocument (none) .br The XmlDocument constructor creates a default xml document. .RE .sp .RS .B XmlDocument (String) .br The XmlDocument constructor creates a xml document by parsing the file. The file name is the string argument. .RE .sp .RS .B XmlDocument (String InputStream) .br The XmlDocument constructor 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. .RE .sp .RS .B XmlDocument (String XmlRoot) .br The XmlDocument constructor 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. .RE .PP .I Methods .br .sp .RS .B set-name -> none (String) .br The set-name method sets the xml document name. The get-name method is available from the nameable base class. .RE .sp .RS .B get-root -> XmlRoot (none) .br The get-root method returns the document xml root node. .RE .sp .RS .B get-body -> XmlRoot (none) .br The get-body method returns the document xml root node body without the declaration node. .RE .PP .B XmlElement .br The XmlElement class 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. .PP .I Predicate .br .sp .RS element-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Constructors .br .sp .RS .B XmlElement (String String) .br The XmlElement constructor creates a xml element by name and value. The first argument is the element name. The second argument is the argument value. .RE .PP .I Methods .br .sp .RS .B set-name -> none (String) .br The set-name method sets the xml element name. .RE .sp .RS .B get-name -> String (none) .br The get-name method returns the element name. .RE .sp .RS .B set-xval -> none (String) .br The set-xval method sets the xml element value. .RE .sp .RS .B get-xval -> String (none) .br The get-xval method returns the element value. .RE .PP .B XmlEntity .br The XmlEntity class 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. .PP .I Predicate .br .sp .RS entity-p .RE .PP .I Inheritance .br .sp .RS XmlNode .RE .PP .I Methods .br .sp .RS .B set-name -> none (String) .br The set-name method sets the entity name. .RE .sp .RS .B get-name -> String (none) .br The get-name method returns the entity name. .RE .PP .B XmlGe .br The XmlGe class 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. .PP .I Predicate .br .sp .RS ge-p .RE .PP .I Inheritance .br .sp .RS XmlEntity .RE .PP .I Constructors .br .sp .RS .B XmlGe (String String) .br The XmlGe constructor 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. .RE .sp .RS .B XmlGe (String String String) .br The XmlGe constructor 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. .RE .sp .RS .B XmlGe (String String String String) .br The XmlGe constructor 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. .RE .PP .I Methods .br .sp .RS .B get-xval -> String (none) .br The get-xval method returns the entity value. .RE .sp .RS .B get-data -> String (none) .br The get-data method returns the entity data type. .RE .sp .RS .B get-public-id -> String (none) .br The get-public-id method returns the entity public identifier. .RE .sp .RS .B get-system-id -> String (none) .br The get-system-id method returns the entity system identifier. .RE .PP .B XmlPe .br The XmlPe class 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. .PP .I Predicate .br .sp .RS ge-p .RE .PP .I Inheritance .br .sp .RS XmlEntity .RE .PP .I Constructors .br .sp .RS .B XmlPe (String String) .br The XmlGe constructor creates a xml entity by name and value. The first argument is the entity name. The second argument is the entity value. .RE .sp .RS .B XmlPe (String String String) .br The XmlGe constructor 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. .RE .PP .I Methods .br .sp .RS .B get-xval -> String (none) .br The get-xval method returns the entity value. .RE .sp .RS .B get-public-id -> String (none) .br The get-public-id method returns the entity public identifier. .RE .sp .RS .B get-system-id -> String (none) .br The get-system-id method returns the entity system identifier. .RE .PP .B XmlReader .br The XmlReader class 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. .PP .I Predicate .br .sp .RS reader-p .RE .PP .I Inheritance .br .sp .RS Object .RE .PP .I Constructors .br .sp .RS .B XmlReader (none) .br The XmlReader constructor creates a default xml reader. .RE .PP .I Methods .br .sp .RS .B reset -> none (none) .br The reset method resets the xml reader. In particular, the root node is restored to the nil node. .RE .sp .RS .B parse -> none (InputStream|String) .br The parse method parses an input stream or a file. During the parsing process, the root node is filled with the parsed nodes. .RE .sp .RS .B get-root -> XmlRoot (none) .br The get-root method returns the parsed root node. .RE .sp .RS .B get-node -> XmlNode (String) .br The get-node method parse a string and returns a node. .RE .PP .B Xne .br The Xne is a nameset that binds constants used by the xne system. .PP .I Constants .br .sp .RS .B ID .br The ID constant defines a node access by id. .RE .sp .RS .B PI .br The PI constant defines an access selector for a processing instruction node. .RE .sp .RS .B GE .br The GE constant defines an access selector for a general entity node. .RE .sp .RS .B TAG .br The TAG constant defines an access selector for a tag node. .RE .sp .RS .B ENT .br The ENT constant defines an access selector for an entity node. .RE .sp .RS .B EREF .br The EREF constant defines an access selector for an entity reference node. .RE .sp .RS .B CREF .br The CREF constant defines an access selector for an character reference node. .RE .sp .RS .B ELEM .br The ELEM constant defines an access selector for an element node. .RE .sp .RS .B TEXT .br The TEXT constant defines an access selector for a text node. .RE .sp .RS .B NAME .br The NAME constant defines a node access by name. .RE .sp .RS .B CDATA .br The CDATA constant defines an access selector for a character data node. .RE .sp .RS .B INDEX .br The INDEX constant defines a node access by child index. The child index is node index seen from the parent. .RE .PP .B XneTree .br The XneTree is 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 copy method. .PP .I Predicate .br .sp .RS xne-tree-p .RE .PP .I Inheritance .br .sp .RS Object .RE .PP .I Constructors .br .sp .RS .B XmlTree (none) .br The XmlTree constructor creates a default tree without a node. .RE .sp .RS .B XmlTree (XmlNode) .br The XmlTree constructor creates a tree with a xml node. The node stored in the object is the root of the tree subject to the operations. .RE .PP .I Methods .br .sp .RS .B depth -> Integer (none) .br The depth method returns the depth of the tree. .RE .sp .RS .B generate-id -> Integer (none) .br The generate-id method generate a unique id for all node in the tree. The id attribute is set by this method. .RE .sp .RS .B set-node -> none (XmlNode) .br The set-node method sets the root tree node. .RE .sp .RS .B get-node -> XmlNode (none) .br The get-node method returns the root tree node. .RE .sp .RS .B set-attribute -> none (none|String) .br The set-attribute method 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. .RE .sp .RS .B clear-attribute -> none (none|String) .br The clear-attribute method 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. .RE .sp .RS .B set-prefix -> none (String) .br The set-prefix method sets a prefix on all nodes in the tree. .RE .sp .RS .B clear-prefix -> none (none) .br The clear-prefix method clear the prefix for all nodes in the tree. .RE .sp .RS .B select -> Vector (XneCond [Boolean]) .br The select method 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 a call with the condition only. .RE .PP .B XneChild .br The XneCond is 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. .PP .I Predicate .br .sp .RS xne-cond-p .RE .PP .I Inheritance .br .sp .RS Object .RE .PP .I Constructors .br .sp .RS .B XneCond (none) .br The XneCond constructor creates a default condition. The default condition is empty. The empty condition always succeeds. .RE .PP .I Methods .br .sp .RS .B add -> none (Xne [String|Integer]) .br The add adds 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. .RE .sp .RS .B valid-p -> Boolean (XmlNode) .br The valid-p predicate checks that a node matches a condition. If the condition succeeds, the predicate returns true. .RE .PP .B XsmNode .br The XsmNode is 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. .PP .I Predicate .br .sp .RS xsm-node-p .RE .PP .I Inheritance .br .sp .RS Object .RE .PP .I Constants .br .sp .RS .B TXT .br The TXT constant defines a xsm text node. .RE .sp .RS .B TAG .br The TAG constant defines a xsm tag node. .RE .sp .RS .B REF .br The REF constant defines a xsm reference node. .RE .sp .RS .B END .br The END constant defines a xsm end node. .RE .PP .I Constructors .br .sp .RS .B XsmNode (none) .br The XsmNode constructor creates a default xsm node which is an empty text node. .RE .sp .RS .B XsmNode (String) .br The XsmNode constructor creates a xsm text node by value. The string argument is the text node value .RE .sp .RS .B XsmNode (Item String) .br The XsmNode constructor creates a xsm text node by type and value. The first argument is the node type. The second argument is the node text value. .RE .PP .I Methods .br .sp .RS .B text-p -> Boolean (none) .br The text-p predicate returns true if the node is a text node. .RE .sp .RS .B tag-p -> Boolean (none) .br The tag-p predicate returns true if the node is a tag node. .RE .sp .RS .B ref-p -> Boolean (none) .br The reference-p predicate returns true if the node is a reference node. .RE .sp .RS .B end-p -> Boolean (none) .br The end-p predicate returns true if the node is a reference node. .RE .sp .RS .B normal-p -> Boolean (none) .br The normal-p predicate returns true if the node is a normal tag node. .RE .sp .RS .B reserved-p -> Boolean (none) .br The reserved-p predicate returns true if the node is a reserved tag node. .RE .sp .RS .B textable-p -> Boolean (none) .br The textable-p predicate returns true if the node is a textable node, that is a text node or a reference node. .RE .sp .RS .B get-source-line -> Integer (none) .br The get-source-line method returns the node source line number if any. .RE .sp .RS .B set-source-line -> none (Integer) .br The set-source-line method sets the node source line number. .RE .sp .RS .B get-source-name -> String (none) .br The get-source-name method returns the node source name if any. .RE .sp .RS .B set-source-name -> none (String) .br The set-source-name method sets the node source name. .RE .sp .RS .B get-name -> String (none) .br The get-name method returns the next available name. name. .RE .PP .B XsmReader .br The XmlReader class is the simple model node reader. The reader operates with the parse method 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. .PP .I Predicate .br .sp .RS xsm-reader-p .RE .PP .I Inheritance .br .sp .RS Object .RE .PP .I Constructors .br .sp .RS .B XsmReader (none) .br The XsmReader constructor creates a default xsm reader. The reader is not bound to any stream. .RE .sp .RS .B XsmReader (InputStream) .br The XsmReader constructor creates a xsm reader with an input stream. The argument is the input bound to the reader. .RE .sp .RS .B XsmReader (String) .br The XsmReader constructor 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 reader. .RE .PP .I Methods .br .sp .RS .B set-input-stream -> none (InputStream) .br The set-input-stream method bind a new input stream to the reader. Subsequent read will use the newly bound stream .RE .sp .RS .B get-node -> XsmNode (none) .br The get-node method parses the input stream and returns the available node. .RE .PP .B XsmDocument .br The XsmDocument class 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. .PP .I Predicate .br .sp .RS document-p .RE .PP .I Inheritance .br .sp .RS Nameable .RE .PP .I Constructors .br .sp .RS .B XsmDocument (none) .br The XsmDocument constructor creates a default xsm document. .RE .sp .RS .B XsmDocument (String) .br The XsmDocument constructor creates a xsm document by name. The string argument is the file name to parse. .RE .sp .RS .B XsmDocument (String InputStream) .br The XsmDocument constructor 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. .RE .PP .I Methods .br .sp .RS .B set-name -> none (String) .br The set-name method sets the xsm document name. The get-name method is available from the nameable base class. .RE .sp .RS .B length -> Integer (none) .br The length method returns the xsm document length. The document length is the number of nodes parsed and stored in the document. .RE .sp .RS .B get-node -> XsmNode (Integer) .br The get-node method returns a document node by index. .RE .sp .RS .B get-info -> XsoInfo (Integer [Boolean]) .br The get-info method 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. .RE .sp .RS .B get-info-vector -> XsoInfo (String [Boolean]) .br The get-info-vetcor method 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. .RE .PP .B XsoInfo .br The XsoInfo class 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. .PP .I Predicate .br .sp .RS xso-info-p .RE .PP .I Inheritance .br .sp .RS Nameable .RE .PP .I Constructors .br .sp .RS .B XsoInfo (none) .br The XsoInfo constructor creates a default info object. .RE .sp .RS .B XsoInfo (String) .br The XsoInfo constructor creates an info object by name. The string argument is the node info name. .RE .sp .RS .B XsoInfo (String String) .br The XsoInfo constructor creates an info object by name and text. The first argument is the node info name. The second argument is the node text information. .RE .PP .I Methods .br .sp .RS .B set-name -> none (String) .br The set-name method sets the info object name. .RE .sp .RS .B set-attribute -> none (String Literal) .br The set-attribute method sets an attribute by name and value. The first argument is the attribute name. The second argument is the attribute value. .RE .sp .RS .B get-attribute-list -> Plist (none) .br The get-attribute-list method returns the node attribute list in the form of a property list object. .RE .sp .RS .B get-attribute-value -> String (String) .br The get-attribute-value method returns the attribute value by name. The string argument is the attribute name. .RE .sp .RS .B set-text -> none (String) .br The set-text method sets the info object text. .RE .sp .RS .B get-text -> String (none) .br The get-text method returns the text information. .RE