%XML.Node
Class %XML.Node Extends %RegisteredObject [ System = 2 ]
For details on using this class, see Representing an XML Document as a DOM.
%XML.Node may be used to navigate the an XML document which is represented as an Document Object Model (DOM) using the %XML.Document. The %XML.Document may be created either
- from an XML document by accessing the Document property of %XML.Reader after calling an Openxxx method of %XML.Reader.
- as a new DOM by calling the CreateDocument of this class.
The %XML.Node instance that is used to navigate the DOM is created using the GetDocumentElement of %XML.Document.
%XML.Node navigates through the nodes of the DOM rather than representing a fixed node in a DOM tree. The MoveToxxx methods are used to move through the DOM. The properties and methods of %XML.Node are then used to retrieve and modify the node contents.
Properties
Document
Property Document As %XML.Document;
The DOM that this %XML.Node instance is navigating. The Document property may be set to change which DOM is being navigated. When the Document is set, %XML.Node is positioned at the document node, i.e. the parent of the root element.
DocId
Property DocId As %String [ Internal ];
Contains document id in DOM global.
NodeId
Property NodeId As %String;
The id of the current node. The NodeId property may be set in order to move the specified node.
Childlist
Property Childlist As %String [ Internal ];
Childlist associated with NodeId
Descriptor
Property Descriptor As %String [ Internal ];
Descriptor associated with NodeId
AttributeList
Property AttributeList As %String [ Internal, MultiDimensional ];
List of attributes
NodeType
Property NodeType As %String [ Calculated ];
Type of node: $$$xmlELEMENTNODE, $$$xmlTEXTNODE, $$$xmlWHITESPACENODE.
NodeData
Property NodeData As %String [ Calculated ];
Value of a character node.
LocalName
Property LocalName As %String [ Calculated ];
Local name for element node.
QName
Property QName As %String [ Calculated ];
Qname for element node. Only used for output as XML when the prefix is valid for the document.
Namespace
Property Namespace As %String [ Calculated ];
XML namespace for element node.
NamespaceIndex
Property NamespaceIndex As %String [ Calculated ];
Index into XML namespace table for element node.
Nil
Property Nil As %Boolean [ Calculated ];
True if xsi:nil or xsi:null specified as true or 1 for this element node.
SkipFlag
Property SkipFlag As %Boolean [ Calculated, Internal ];
True if node is to be skipped during canonicalization.
Methods
DocumentSet
Method DocumentSet(document As %XML.Document) As %Status [ Internal ]
NodeIdSet
Method NodeIdSet(id As %String) As %Status [ Internal ]
When setting NodeId, the descriptor part must be recomputed in case the tree has been updated.
NodeTypeGet
Method NodeTypeGet() As %String [ CodeMode = expression, Internal ]
NodeTypeSet
Method NodeTypeSet(type As %String) As %Status [ Internal ]
NodeDataGet
Method NodeDataGet() As %String [ Internal ]
NodeDataSet
Method NodeDataSet(val As %String) As %Status [ Internal ]
GetText
Method GetText(ByRef text, mixed As %Boolean = 0) As %Boolean
Get the text contents of an element node. GetText returns false if an error is encountered in evaluating the node. GetText returns true if text is found. The text which is found may be the empty string. The found text is appended to the text argument. The text argument is created if it is not already defined. If the mixed argument is = 1, then the mixed character and element content in the current node is returned in the text argument.
LocalNameGet
Method LocalNameGet() As %String [ CodeMode = expression, Internal ]
LocalNameSet
Method LocalNameSet(name As %String) As %Status [ Internal ]
QNameGet
Method QNameGet() As %String [ CodeMode = expression, Internal ]
QNameSet
Method QNameSet(name As %String) As %Status [ Internal ]
NamespaceGet
Method NamespaceGet() As %String [ CodeMode = expression, Internal ]
NamespaceSet
Method NamespaceSet(namespace As %String) As %Status [ Internal ]
NamespaceIndexGet
Method NamespaceIndexGet() As %String [ Internal ]
NamespaceIndexSet
Method NamespaceIndexSet(nsIndex As %String) As %Status [ Internal ]
NilGet
Method NilGet() As %Boolean [ CodeMode = expression, Internal ]
NilSet
Method NilSet(value As %Boolean) As %Status [ Internal ]
SkipFlagGet
Method SkipFlagGet() As %Boolean [ CodeMode = expression, Internal ]
SkipFlagSet
Method SkipFlagSet(value As %Boolean) As %Status [ Internal ]
MoveToParent
Method MoveToParent(restrictDocumentNode As %Boolean = 0) As %Boolean
Move node to current node's parent.
If restrictDocumentNode is true, then MoveTopParent will not move to document node.
MoveToParentElement
Method MoveToParentElement(localName As %String) As %Boolean
Move node to current node's ancestor which has the specified local name.
HasChildNodes
Method HasChildNodes(skipWhitespace As %Boolean = 0) As %Boolean
Return non-zero (true) if this node has any child nodes.
MoveToFirstChild
Method MoveToFirstChild(skipWhitespace As %Boolean = 0) As %Boolean
Move node to current node's first child node. Optionally skip whitespace nodes.
MoveToLastChild
Method MoveToLastChild(skipWhitespace As %Boolean = 0) As %Boolean
Move node to current node's last child node. Optionally skip whitespace nodes.
MoveToNextSibling
Method MoveToNextSibling(skipWhitespace As %Boolean = 0) As %Boolean
Move node to current node's next sibling. Optionally skip whitespace nodes.
MoveToPreviousSibling
Method MoveToPreviousSibling(skipWhitespace As %Boolean = 0) As %Boolean
Move node to current node's previous sibling. Optionally skip whitespace nodes.
IsDescendant
Method IsDescendant(sourceNode As %XML.Node) As %Boolean
Check is a this node is the descendant of specified node
CopyAttributes
Method CopyAttributes(sourceNode As %XML.Node) [ Internal ]
Copy the attributes of the source node to this node.
AppendElement
Method AppendElement(localName As %String, namespace As %String = "", text As %String, qname As %String = "")
Append new element node to the list of children of this node. If the text argument is specified, then character data is added as the child of the new element. The current node pointer does not change. This node is still the parent of the appended child.
AppendCharacter
Method AppendCharacter(text As %String, raw As %Boolean, parent As %String)
Append new character data node to the list of children of this element node. The current node pointer does not change. This node is still the parent of the appended child.
If raw is true, the node is marked as $$$xmlRAWTEXTNODE
parent is for internal use only.
AppendNode
Method AppendNode(sourceNode As %XML.Node) As %Status
Append a copy of the specified node to the list of children of this node. The node to copy may be from any document. The current node pointer does not change. This node is still the parent of the appended child.
AppendTree
Method AppendTree(sourceNode As %XML.Node) As %Status
Append a copy of the specified node, including all its children, to the list of children of this node. The tree to copy may be from any document, but this node may not be a descendant of the source node. The current node pointer does not change. This node is still the parent of the appended child.
InsertElement
Method InsertElement(localName As %String, namespace As %String = "", ByRef child As %String, text As %String, qname As %String = "") As %String
Insert a new element node to the list of children of this node. The new element is inserted just before the specified child node. The child node is specified by passing its NodeId. The child node is passed by reference so that it may be updated with a new NodeId after the insert. The nodeId of the inserted element is returned. If the text argument is specified, then character data is added as the child of the new element. The current node pointer does not change. This node is still the parent of the appended child.
InsertCharacter
Method InsertCharacter(text As %String, ByRef child As %String) As %String
Insert a new character data node to the list of children of this element node. The new character data is inserted just before the specified child node. The child node is specified by passing its NodeId. The child node is passed by reference so that it may be updated with a new NodeId after the insert. The nodeId of the inserted character data node is returned. The current node pointer does not change. This node is still the parent of the appended child.
InsertNode
Method InsertNode(sourceNode As %XML.Node, ByRef child As %String, Output sc As %Status) As %String
Insert a copy of the specified node to the list of children of this node. The node to copy may be from any document. The new node is inserted just before the specified child node. The child node is specified by passing its NodeId. The child node is passed by reference so that it may be updated with a new NodeId after the insert. The nodeId of the inserted node is returned. The current node pointer does not change.
InsertTree
Method InsertTree(sourceNode As %XML.Node, ByRef child As %String, Output sc As %Status) As %String
Insert a copy of the specified node, including its children, to the list of children of this node. The tree to copy may be from any document, but this node may not be a descendant of the source node. The new node is inserted just before the specified child node. The child node is specified by passing its NodeId. The child node is passed by reference so that it may be updated with a new NodeId after the insert. The nodeId of the inserted node is returned. The current node pointer does not change.
ReplaceElement
Method ReplaceElement(localName As %String, namespace As %String = "", text As %String, qname As %String = "")
Replace this node with an element node.
ReplaceCharacter
Method ReplaceCharacter(text As %String)
Replace this node with a character node.
ReplaceNode
Method ReplaceNode(sourceNode As %XML.Node) As %Status
Replace this node with a copy of the specified node. The node to copy may be from any document. The current node pointer does not change.
ReplaceTree
Method ReplaceTree(sourceNode As %XML.Node) As %Status
Replace this node with a copy of the specified node including all its children. The tree to copy may be from any document, but this node may not be a descendant of the source node. The current node pointer does not change.
Remove
Method Remove()
Remove the current node and make its parent the current node.
GetAttributeList
Method GetAttributeList() [ Internal ]
Get array of attributes: ..AttributeList(name)=attribute
GetNumberAttributes
Method GetNumberAttributes() As %Integer [ CodeMode = expression ]
Return number of attributes for this element.
AttributeDefined
Method AttributeDefined(attributeName As %String) As %String
Return non-zero (true) if attribute named attributeName exists for this element.
FirstAttributeName
Method FirstAttributeName() As %String
Return attribute name for first attribute for this element.
LastAttributeName
Method LastAttributeName() As %String
Return attribute name for last attribute for this element.
NextAttributeName
Method NextAttributeName(attributeName As %String) As %String
Return attribute name for next attribute for this element.
PreviousAttributeName
Method PreviousAttributeName(attributeName As %String) As %String
Return attribute name for previous attribute for this element.
GetAttribute
Method GetAttribute(attributeName As %String, ByRef namespace As %String, ByRef value As %String, ByRef valueNamespace As %String)
Return attribute data of attribute named attributeName for this element.
- namespace is the namespace URI from QName of attribute named attributeName for this element.
- value is the attribute value.
- valueNamespace is the namespace URI corresponding to the prefix when the attribute value is of the form "prefix:value".
GetAttributeNS
Method GetAttributeNS(attributeName As %String, namespace As %String, ByRef value As %String, ByRef valueNamespace As %String)
Return attribute data of attribute named attributeName in namespace for this element.
- value is the attribute value.
- valueNamespace is the namespace URI corresponding to the prefix when the attribute value is of the form "prefix:value".
GetAttributeNamespace
Method GetAttributeNamespace(attributeName As %String) As %String
Return namespace URI from QName of attribute named attributeName for this element.
GetAttributeValue
Method GetAttributeValue(attributeName As %String) As %String
Return value of attribute named attributeName for this element.
GetAttributeValueNS
Method GetAttributeValueNS(attributeName As %String, namespace As %String) As %String
Return value of attribute named attributeName in namespace for this element.
GetAttributeQName
Method GetAttributeQName(attributeName As %String) As %String
Return QName of attribute named attributeName for this element.
GetAttributeQNameNS
Method GetAttributeQNameNS(attributeName As %String, namespace As %String) As %String
Return QName of attribute named attributeName in namespace for this element.
GetAttributeValueNamespace
Method GetAttributeValueNamespace(attributeName As %String) As %String
Return namespace of value of attribute named attributeName for this element.
GetAttributeValueNamespaceNS
Method GetAttributeValueNamespaceNS(attributeName As %String, namespace As %String) As %String
Return namespace value of attribute named attributeName in namespace for this element.
SetAttribute
Method SetAttribute(attributeName As %String, namespace As %String = "", value As %String = "", valueNamespace As %String = "")
Set attribute data of attribute named attributeName for this element.
- namespace is the namespace URI from QName of attribute named attributeName for this element.
- value is the attribute value.
- valueNamespace is the namespace URI corresponding to the prefix when the attribute value is of the form "prefix:value".
RemoveAttribute
Method RemoveAttribute(attributeName As %String)
Remove attribute named attributeName for this element.
RemoveAttributeNS
Method RemoveAttributeNS(attributeName As %String, namespace As %String)
Remove attribute named attributeName in namespace for this element.
IsAncestor
Method IsAncestor(nodeId As %String) As %Boolean [ Internal ]
Verify if this node is an ancestor of the specified node. Check if the referenced element contains the element specified by node id.
Serialize
Method Serialize(Output endElementText) As %String
Serialize this node as element
GetClassName
Method GetClassName(BaseClassName As %String) As %String [ Internal ]
Get the class name the corresponds to this element. Return "" if not found.