IGLib  1.7.2
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.Lib.XmlBuilder Class Reference

Class that enables custom parsing and building of an Xml document. More...

+ Inheritance diagram for IG.Lib.XmlBuilder:
+ Collaboration diagram for IG.Lib.XmlBuilder:

Public Member Functions

void NewDocument ()
 Creates a new Xml document. More...
 
void NewDocument (string RootName)
 Creates a new Xml document with a specified name of hte root element. More...
 
XmlNode Discard ()
 Discards the newly created node and returns it if it exists. More...
 
XmlNode SetAttribute (string name, string value)
 Sets a named attribute of the currently treated node to a specific value. This only works if the currently treated node is an XML element. If an attribute with a specified name dose not yet exist then it is created, otherwise old value is overwritten. More...
 
XmlNode RemoveAttribute (string name)
 Removes the attribute with a specified name from the currently treated XML node, and returns this node or null if the operation was not successful (e.g. if the treated node is not defined or if the attribute with a specified name does not exist). This function does not report any errors. More...
 
XmlNode SetValue (string value)
 Sets value of the currently treated XML node. If the currently treated node is a text node then value is set directly. If the currently treated node is an element then value is set on its first chilld text node if such a node exists. If the element has no children, a text child node is created. More...
 
XmlNode SetInnerText (string value)
 Sets inner text of the currently treated XML node. More...
 
XmlNode RemoveNode (XmlNode node)
 Removes the specified node from the current XML document and returns that node. null is returned if the node can not be removed. CAUTION: Removing the node may destroy information about previous node and thus render the Back() operation impossible. It may also affect marks, which is not checked by any function but the BackMark() following removal may fail. More...
 
XmlNode RemoveCurrent ()
 Removes the current node and returns the removed node or null if the operation does not succeed. The current node is moved to the next node and may become null if the current node was the last one in the given child list. More...
 
- Public Member Functions inherited from IG.Lib.XmlParser
string Attribute (string key)
 Returns the value of the specified attribute of the current node. If the attribute does not exist then null is returned. More...
 
XmlNode GetNode (string path)
 Returns the first node that satisfies a given XPath expression relative to the root node. It does not report any errors (just returns null in case of errors) More...
 
XmlNode GetRelative (string path)
 Returns the first node that satisfies a given XPath expression relative to the current node. It does not report any errors. More...
 
XmlNode GetNextNode (XmlNodeType NodeType, string NodeName, string NodeValue)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode GetNextNode (XmlNodeType NodeType, string NodeName)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode GetNextNode (XmlNodeType NodeType)
 Moves the current node to the first sibling node after the current node that is of the specified type. More...
 
XmlNode GetNextNode (string NodeName, string NodeValue)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. Node type is not important. More...
 
XmlNode GetNextNode (string NodeName)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. Node type is not important. More...
 
XmlNode GetNextOrCurrentNode (XmlNodeType NodeType, string NodeName, string NodeValue)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode GetNextOrCurrentNode (XmlNodeType NodeType, string NodeName)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode GetNextOrCurrentNode (XmlNodeType NodeType)
 Moves the current node to the current or the first sibling node after the current node that is of the specified type. More...
 
XmlNode GetNextOrCurrentNode (string NodeName, string NodeValue)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. Node type is not important. More...
 
XmlNode GetNextOrCurrentNode (string NodeName)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. Node type is not important. More...
 
XmlNode GetNextElement (string NodeName, string NodeValue)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode GetNextElement (string NodeName)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode GetNextElement ()
 Moves the current node to the first sibling element after the current node. More...
 
XmlNode GetNextOrCurrentElement (string NodeName, string NodeValue)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode GetNextOrCurrentElement (string NodeName)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode GetNextOrCurrentElement ()
 Moves the current node to the current or the first sibling element after the current node. More...
 
void SetMark (string name)
 Marks the current state of the XmlParser and sets mark name to name. Position is stored on a stack such that previous stored positions can be restored, either in a reverse way. More...
 
void SetMark ()
 Marks the current state of the XmlParser. The mark set is not named. Position is stored on a stack such that previous stored positions can be restored, either in a reverse way. More...
 
XmlNode GoToMark (bool removemarks)
 Restores the parser state to the state contained in the last mark. The current node after operation is returned, or null if there are no marks. If required then the last mark is removed from the list. More...
 
XmlNode GoToMark (string name, bool removemarks)
 Restores the parser state to the state contained in the last mark with the specified name. The current node after operation is returned, or null if there are no marks with such a name. If required then the targeted and all subsequent marks are removed from the list. More...
 
XmlNode GoToMark ()
 Restores the parser state to the state contained in the last mark. The current node after operation is returned, or null if there are no marks. The last mark is LEFT on the list. More...
 
XmlNode GoToMark (string name)
 Restores the parser state to the state contained in the last mark with the specified name. The current node after operation is returned, or null if there are no marks with such a name. More...
 
XmlNode BackToMark ()
 Restores the parser state to the state contained in the last mark, and REMOVES that mark. The current node after operation is returned, or null if there are no marks. More...
 
XmlNode BackToMark (string name)
 Restores the parser state to the state contained in the last mark with the specified name, and REMOVES all marks from that mark on (includively). The current node after operation is returned, or null if there are no marks with such a name. More...
 
XmlNode RemoveMark ()
 Removes the last mark and returns its current node. Position is not affected. More...
 
XmlNode RemoveMarks (string name)
 Removes all marks from the last mark with the specified name on the list and returns the current node of the specified mark. Position is not affected. More...
 
XmlNode Back ()
 Moves the current to the previous node, if that node exists. Only one step backwards is enabled. More...
 
XmlNode MoveTo (XmlNode node)
 Moves the current position to the specified node. More...
 
XmlNode MoveTo (string path)
 Moves the current position to the first node that satisfies the absolute path specified as an XPath string. More...
 
XmlNode MoveRelative (string path)
 Moves the current position to the first node that satisfies the relative path specified as an XPath string relative to the current node. More...
 
XmlNode GoToParent ()
 Sets the current node to the parent node of the current node and returns it. This also works if the Current node is null because the advancing fell out of range or because StepIn was executed but there were no child _gridCoordinates of the current node. More...
 
XmlNode GoToRoot ()
 Sets the current node to the root node of the current document and returns it. More...
 
XmlNode GoToDocument ()
 Sets the current node to the root node of the current document and returns it. More...
 
XmlNode StepIn ()
 Moves the current node to its first child node and returns the node. More...
 
XmlNode StepOut ()
 Steps out of the current childnodes context and selects the next node of the parent as the current node. This also works if the Current node is null because the advancing fell out of range or because StepIn was executed but there were no child _gridCoordinates of the current node. More...
 
XmlNode NextNode ()
 Sets the current node to the next sibling node, or to null if the next sibling node does not exist, and returns that node. More...
 
XmlNode NextNodeConditional (XmlNodeType NodeType, string NodeName, string NodeValue, bool IncludeCurrent)
 Moves the current node to the first sibling node of the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode NextNode (XmlNodeType NodeType, string NodeName, string NodeValue)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode NextNode (XmlNodeType NodeType, string NodeName)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode NextNode (XmlNodeType NodeType)
 Moves the current node to the first sibling node after the current node that is of the specified type. More...
 
XmlNode NextNode (string NodeName, string NodeValue)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. Node type is not important. More...
 
XmlNode NextNode (string NodeName)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. Node type is not important. More...
 
XmlNode NextOrCurrentNode (XmlNodeType NodeType, string NodeName, string NodeValue)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode NextOrCurrentNode (XmlNodeType NodeType, string NodeName)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode NextOrCurrentNode (XmlNodeType NodeType)
 Moves the current node to the current or the first sibling node after the current node that is of the specified type. More...
 
XmlNode NextOrCurrentNode (string NodeName, string NodeValue)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. Node type is not important. More...
 
XmlNode NextOrCurrentNode (string NodeName)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. Node type is not important. More...
 
XmlNode NextElement (string NodeName, string NodeValue)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode NextElement (string NodeName)
 Moves the current node to the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode NextElement ()
 Moves the current node to the first sibling element after the current node. More...
 
XmlNode NextOrCurrentElement (string NodeName, string NodeValue)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode NextOrCurrentElement (string NodeName)
 Moves the current node to the current or the first sibling node after the current node that satisfies the specified conditions, and returns the current node. More...
 
XmlNode NextOrCurrentElement ()
 Moves the current node to the current or the first sibling element after the current node. More...
 
- Public Member Functions inherited from IG.Lib.XmlUtilityBase
virtual void SetDocument (XmlDataDocument doc)
 
virtual void Load (string filename)
 
virtual void LoadXml (string docstr)
 

Protected Attributes

XmlNode _new = null
 

Properties

XmlNode Treated [get]
 Returns the Xml node that is currently treaded. All modifications apply to this node. If a newly created node exists that has not been inserted into the document yet then this node is returned. Otherwise, the current node is returned. More...
 
XmlElement TreatedElement [get]
 Returns Treated if this node is Xml element, or null if it is not or if treated is null. More...
 
XmlNode NewNode [get, set]
 Gets or sets the newly created node (if one exists). When the newly created node is inserted into the document, it is not accessible any more through NewNode or Treated properties. If set to a node from another document, a deep copy is created and imported. If set to a node from the current document that is already included in the document, a deep copy is created and set. If set to a node from the current document that is not included in the document, a reference to the node is set. More...
 
XmlElement NewElement [get]
 Returns NewNode if it is an Xml Element, or null if it is not. More...
 
- Properties inherited from IG.Lib.XmlParser
override XmlDocument Doc [get, set]
 Xml document that represents the message. More...
 
XmlNode Current [get, set]
 The current node on which all queries are performed. More...
 
XmlNode Previous [get, set]
 The node that was previously set to the current node. More...
 
XmlNode Parent [get, private set]
 Parent of Current. If Current = null then Parent can still return something, which happens in particular when StepIn was performed before. Parent can be set to a specific node. That node will be returned by Parent when the Current is null (otherwise, the parent of Current is still returned). This is useful when current becomes null, e.g. because of running out of index bounds. More...
 
XmlElement ParentElement [get]
 
XmlElement CurrentElement [get]
 
XmlElement PreviousElement [get]
 
string Name [get]
 Returns the name of the current node. More...
 
string Value [get]
 Returns the value of the current node. If the current node is an element then the value of its first text child element is returned. More...
 
string InnerText [get]
 Returns the inner text of the current node. More...
 
- Properties inherited from IG.Lib.XmlUtilityBase
virtual IG.Lib.IReporter R [get]
 Reporter for this class. More...
 
virtual bool HasDefaultNameSpace [get, protected set]
 
string FileName [get, protected set]
 
virtual XmlDocument Doc [get, set]
 Xml document that represents the message. More...
 
XmlNode Root [get, private set]
 Root node of the current document. More...
 

Private Member Functions

XmlDocument NewXmlDocument ()
 
XmlDocument NewXmlDocument (string RootName)
 
XmlNode CreateNode (XmlNodeType type, string name, string value, string namespaceURI)
 Creates a new node and sets this node as treated node. If there already exist a newly created node then it must be unassigned first (e.g. by Discard()), otherwise this method fails. The new node also gets unassigned when it is inserted into the document. More...
 
XmlNode InsertBefore ()
 Inserts the newly created node before the current node. The new node is set to null if the operation is successful (otherwise it remains unchanged). More...
 
XmlNode InsertAfter ()
 Inserts the newly created node after the current node. The new node is set to null if the operation is successful (otherwise it remains unchanged). More...
 
XmlNode AppendChild ()
 Appends the newly created node after the last child of the current node. The new node is set to null if the operation is successful (otherwise it remains unchanged). More...
 
XmlNode PrependChild ()
 Inserts the newly created node before the first child of the current node. The new node is set to null if the operation is successful (otherwise it remains unchanged). More...
 

Additional Inherited Members

- Static Public Member Functions inherited from IG.Lib.XmlParser
static XmlNode GetNextNode (XmlNode StartingNode, XmlNodeType NodeType, string NodeName, string NodeValue, bool IncludeCurrent)
 Finds the first sibling node of the starting node (or the current node itself) that satisfies the specified conditions, and returns that node or null if such a node could not be found. This method does not report errors, it just returns null if the node satisfying conditions can not be found. More...
 
- Static Public Member Functions inherited from IG.Lib.XmlUtilityBase
static string GetDefaultNameSpaceUri (XmlElement element)
 Gets the default namespace URI if defined, for the specified Xml element. More...
 
static string GetDefaultNameSpaceUri (XmlDocument doc)
 Gets the default namespace URI of teh Xml document. More...
 
static string GetDefaultNameSpaceUri (XmlNode node)
 Returns the default namespace URI that applies to the specified Xml node. More...
 
static string GetNameSpaceUri (XmlDocument doc, string prefix)
 Returns the namespace URI associated with a specific prefix that applies to the specified Xml document. More...
 
static string GetNameSpaceUri (XmlNode node, string prefix)
 Returns the namespace URI associated with a specific prefix that applies to the specified Xml document. More...
 
- Public Attributes inherited from IG.Lib.XmlUtilityBase
string DefaultNameSpace = null
 
string DefaultNameSpacePrefix = "defaultnsprefix"
 
- Protected Member Functions inherited from IG.Lib.XmlParser
XmlNode GoToMark (Mark mark)
 Restores the parser state that is stored in the specified mark. The current node after operation is returned, or null if mark is not specified (i.e., it is null). More...
 
- Protected Member Functions inherited from IG.Lib.XmlUtilityBase
bool ContainedInDocument (XmlNode node, XmlDocument doc)
 Returns true if an Xml node is contained in the specified Xml document (false if any is null). More...
 
bool ContainedInNode (XmlNode node, XmlNode container)
 Returns null if an XML node (first argument) is contained in the specified note (second argument). The node can be contained in another node at an arbitrary depth for the function to return true. If any of the _gridCoordinates is null then the function returns false. More...
 

Detailed Description

Class that enables custom parsing and building of an Xml document.

Member Function Documentation

XmlDocument IG.Lib.XmlBuilder.NewXmlDocument ( )
inlineprivate
XmlDocument IG.Lib.XmlBuilder.NewXmlDocument ( string  RootName)
inlineprivate
void IG.Lib.XmlBuilder.NewDocument ( )
inline

Creates a new Xml document.

void IG.Lib.XmlBuilder.NewDocument ( string  RootName)
inline

Creates a new Xml document with a specified name of hte root element.

Parameters
RootNameName of the root element.
XmlNode IG.Lib.XmlBuilder.Discard ( )
inline

Discards the newly created node and returns it if it exists.

Returns
The discarded Xml node or null if there was no newly created node.
XmlNode IG.Lib.XmlBuilder.SetAttribute ( string  name,
string  value 
)
inline

Sets a named attribute of the currently treated node to a specific value. This only works if the currently treated node is an XML element. If an attribute with a specified name dose not yet exist then it is created, otherwise old value is overwritten.

Parameters
nameName of the attribute to be set.
valueValue of the attribute.
Returns
The node for which the attribute has been set, or null if the attribute could not be set.
XmlNode IG.Lib.XmlBuilder.RemoveAttribute ( string  name)
inline

Removes the attribute with a specified name from the currently treated XML node, and returns this node or null if the operation was not successful (e.g. if the treated node is not defined or if the attribute with a specified name does not exist). This function does not report any errors.

Parameters
nameName of the attribute to be removed.
Returns
The node on which atttribute is removed (which is the currently treated node), or null if the operation could not be performed (this function does not report any errors).
XmlNode IG.Lib.XmlBuilder.SetValue ( string  value)
inline

Sets value of the currently treated XML node. If the currently treated node is a text node then value is set directly. If the currently treated node is an element then value is set on its first chilld text node if such a node exists. If the element has no children, a text child node is created.

XmlNode IG.Lib.XmlBuilder.SetInnerText ( string  value)
inline

Sets inner text of the currently treated XML node.

XmlNode IG.Lib.XmlBuilder.RemoveNode ( XmlNode  node)
inline

Removes the specified node from the current XML document and returns that node. null is returned if the node can not be removed. CAUTION: Removing the node may destroy information about previous node and thus render the Back() operation impossible. It may also affect marks, which is not checked by any function but the BackMark() following removal may fail.

Parameters
nodeXML node to be removed.
XmlNode IG.Lib.XmlBuilder.RemoveCurrent ( )
inline

Removes the current node and returns the removed node or null if the operation does not succeed. The current node is moved to the next node and may become null if the current node was the last one in the given child list.

XmlNode IG.Lib.XmlBuilder.CreateNode ( XmlNodeType  type,
string  name,
string  value,
string  namespaceURI 
)
inlineprivate

Creates a new node and sets this node as treated node. If there already exist a newly created node then it must be unassigned first (e.g. by Discard()), otherwise this method fails. The new node also gets unassigned when it is inserted into the document.

Parameters
type
name
value
namespaceURI
Returns
XmlNode IG.Lib.XmlBuilder.InsertBefore ( )
inlineprivate

Inserts the newly created node before the current node. The new node is set to null if the operation is successful (otherwise it remains unchanged).

Returns
The newly created node if operation is successful, null otherwise.
XmlNode IG.Lib.XmlBuilder.InsertAfter ( )
inlineprivate

Inserts the newly created node after the current node. The new node is set to null if the operation is successful (otherwise it remains unchanged).

Returns
The newly created node if operation is successful, null otherwise.
XmlNode IG.Lib.XmlBuilder.AppendChild ( )
inlineprivate

Appends the newly created node after the last child of the current node. The new node is set to null if the operation is successful (otherwise it remains unchanged).

Returns
The newly created node if operation is successful, null otherwise.
XmlNode IG.Lib.XmlBuilder.PrependChild ( )
inlineprivate

Inserts the newly created node before the first child of the current node. The new node is set to null if the operation is successful (otherwise it remains unchanged).

Returns
The newly created node if operation is successful, null otherwise.

Member Data Documentation

XmlNode IG.Lib.XmlBuilder._new = null
protected

Property Documentation

XmlNode IG.Lib.XmlBuilder.Treated
get

Returns the Xml node that is currently treaded. All modifications apply to this node. If a newly created node exists that has not been inserted into the document yet then this node is returned. Otherwise, the current node is returned.

XmlElement IG.Lib.XmlBuilder.TreatedElement
get

Returns Treated if this node is Xml element, or null if it is not or if treated is null.

XmlNode IG.Lib.XmlBuilder.NewNode
getset

Gets or sets the newly created node (if one exists). When the newly created node is inserted into the document, it is not accessible any more through NewNode or Treated properties. If set to a node from another document, a deep copy is created and imported. If set to a node from the current document that is already included in the document, a deep copy is created and set. If set to a node from the current document that is not included in the document, a reference to the node is set.

XmlElement IG.Lib.XmlBuilder.NewElement
get

Returns NewNode if it is an Xml Element, or null if it is not.


The documentation for this class was generated from the following file: