PrevNextUpHome BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1

18.2. Structure of XML Classes

18.2.1. Classes for Creating Nodes for the DOM Tree

SophiaFramework provides you with the following 12 types of node classes defined by W3C. These classes inherit from the SFXXMLNode class.

Table 18.1. XML Node Class

Class name Description Node Type ( SFXXMLNode::NodeType )
SFXXMLNode Base class for 12 types of node classes -
SFXXMLElement Class that represents an Element node ELEMENT_NODE
SFXXMLAttribute Class that represents an Attribute node ATTRIBUTE_NODE
SFXXMLText Class that represents a Text node TEXT_NODE
SFXXMLCDATASection Class that represents a CDATASection node CDATA_SECTION_NODE
SFXXMLEntityReference Class that represents an Entity Reference node ENTITY_REFERENCE_NODE
SFXXMLEntity Class that represents an Entity node ENTITY_NODE
SFXXMLProcessingInstruction Class that represents a Processing Instruction node PROCESSING_INSTRUCTION_NODE
SFXXMLComment Class that represents a Comment node COMMENT_NODE
SFXXMLDocument Class that represents a Document node DOCUMENT_NODE
SFXXMLDocumentType Class that represents a DocumentType node DOCUMENT_TYPE_NODE
SFXXMLDocumentFragment Class that represents a DocumentFragment node DOCUMENT_FRAGMENT_NODE
SFXXMLNotation Class that represents a Notation node NOTATION_NODE

Figure 18.1. DOM Tree of the SFXXMLNode nodes

DOM Tree of the SFXXMLNode nodes

18.2.2. Basic Function of SFXXMLNode

The following are provided as basic functions of the SFXXMLNode class.

Table 18.2. Function to get a node from the DOM tree

Function Name Description
GetFirstChild get the first child node
GetLastChild get the last child node
GetNextSibling get the next node amongst brothers
GetPreviousSibling get the previous node amongst brothers
GetParentNode get the parent node

Table 18.3. Function to create or update the DOM tree

Function Name Description
AppendChild append a child node
RemoveChild remove a child node
ReplaceChild replace a child node
InsertBefore insert a node
CloneNode clone a node(It is possible to copy a node including child node trees)

Table 18.4. Function to get or set the node attribute

Function Name Description
HasChildNodes test if it has a child node
GetChildNodes get all the child nodes
GetNodeType get a node type
GetNodeName get a node name
SetNodeValue set node contents
GetText get texts included in all the child nodes
SetText set a text into its child node

Table 18.5. Function to compare nodes

Function Name Description
IsSameNode test if two nodes are same
EqualNode test if two nodes are equal

18.2.3. Structure of the DOM Tree

An XML parser receives XML documents grammatically checked by DTD or XML Schema, expands the documents onto memory as tree-structured objects ( DOM tree ), and sends them to an application.

Figure 18.2. Process Flow on XML parser

Process Flow on XML parser

In SophiaFramework, a DOM parser ( SFXXMLDOMParser / SFXXSDDOMParser ) is created to analyze XML document, and return an DOM tree of SFXXMLDocument.

Figure 18.3. Sequence Diagram

Sequence Diagram
[Note] SFXXMLScanner

SFXXMLScanner is the class used by SophiaFramework.

Figure 18.4. SFXXMLDocument

SFXXMLDocument

The most important object in parsing XML document is the root node of SFXXMLDocument in the DOM tree.

Basic Functions of "SFXXMLDocument"

  1. get, create, update, and compare the nodes of the DOM tree
  2. create a new node type
  3. save a XML document
  4. get any node of the DOM tree as Helper function