NAME

domNode -
Manipulates an instance of a DOM node object

SYNOPSIS

 $nodeObject method  arg arg ...

DESCRIPTION

This command manipulates one particular instance of a DOM node object. method indicates a specific method of the node class. These methods should closely conform to the W3C recommendation "Document Object Model (Core) Level 1" (http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html) as well to parts of the W3C draft "XML Pointer Language (XPointer)" (http://www.w3.org/TR/1998/WD-xptr-19980303).

The selectNodes method implements (partially) the "XML Path Language (XPath) Version 1.0" W3C recommendation 16 November 1999 (http://www.w3.org/TR/1999/REC-xpath-19991116). Look at these documents for a deeper understanding of the functionality.

The valid methods are:

nodeType
Returns the node type of that node object. This can be: ELEMENT_NODE, ATTRIBUTE_NODE, TEXT_NODE, or CDATA_SECTION_NODE.
nodeName
Returns the node name of that node object. This is the element (tag) name for element nodes (type ELEMENT_NODE), "#text" for text node or "#cdata" for cdata section nodes.
nodeValue
Returns the value of that node object. This is the the text or the data for element nodes of type TEXT_NODE or CDATA_SECTION_NODE). Otherwise it is empty.
hasChildNodes
Returns 1 if the has children. Otherwise 0 is returned.
parentNodes
Returns the parent node.
childNodes
Returns a list of direct children node objects.
childNodes
Returns a "live" nodeList object of the child nodes of the node in the sense of the DOM recommendation. This nodeList object is "live" in the sense that, for instance, changes to the children of the node object that it was created from are immediately reflected in the nodes returned by the NodeList accessors; it is not a static snapshot of the content of the node. The both accessors know by the nodeList object are "item <index>", which returns the indexth item in the collection, and "length", which returns the number of nodes in the list.
firstChild objVar
Returns the first child as a node object.
lastChild objVar
Returns the last child as a node object.
nextSibling objVar
Returns the next sibling relativ to the current node as a node object.
previousSibling objVar
Returns the next sibling relativ to the current node as a node object.
getElementsByTagName name
Returns a list of all elements in the subtree matching (glob style) name.
getElementsByTagNameNS uri name
...todo... Returns a list of all elements in the subtree matching (glob style) name and having the given namespace uri.
getElementById id
Returns the node having a id attribute with value id.
hasAttribute attributeName
Returns 1 iff the object node contains an attribute with name attributeName . Otherwise 0 is returned.
getAttribute attributeName defaultValue
Returns the value of the attribute attributeName. If attribute is not available defaultValue is returned.
setAttribute attributeName newValue ?attributeName newValue
Sets the value for an attribute attributeName to newValue. This will create a new attribute, if it wasn't avialble before.
removeAttribute attributeName
Removes the attribute attributeName.
hasAttributeNS uri attributeName
...todo... Returns 1 if the object node contains an attribute with name attributeName and a namespace URI uri. Otherwise 0 is returned.
getAttributeNS uri attributeName defaultValue
...todo... Returns the value of the attribute attributeName having the URI uri. If attribute is not available defaultValue is returned.
setAttributeNS uri attributeName newValue
...todo... Sets the value for an attribute attributeName with the namespace URI uri to newValue. This will create a new attribute, if it wasn't avialble before.
removeAttributeNS uri attributeName
...todo... Removes the attribute attributeName having the namespace URI uri.
attributes attributeNamePattern
Returns all attributes matching the attributeNamePattern. If attributeNamePattern isn't given all attributes are returned as a Tcl list.
appendChild newChild
Append newChild to the end of the child list of the node. newChild must be in the document fragment list.
insertBefore newChild refChild
Insert newChild before the refChild in list of children of that node. newChild must be in the document fragment list.
replaceChild newChild oldChild
Replace newChild with oldChild in list of children of that node. newChild must be in the document fragment list. oldChild will be part of the document fragment list after this operation.
removeChild child
Removes child from the list of children of that node child will be part of the document fragment list after this operation. It is not physically deleted.
delete
...todo... Deletes the given node and its complete child tree and frees the complete internal memory. The affected nodes are not accessible through the document fragment list.
cloneNode -deep
Clones this node and adds the new create node into the document fragment list. If the -deep option is specified, all descendant nodes are also cloned.
ownerDocument
Returns the document object of the document this node belongs to.
find attrName attrVal objVar
Finds the node with the attribute name attrName, and attribute value attrVal in the subtree starting the current node.
child number|all type attrName attrValue
(XPointer) child
descendant number|all type attrName attrValue
(XPointer) descendant
ancestor number|all type attrName attrValue
(XPointer) ancestor
fsibling number|all type attrName attrValue
(XPointer) fsibling
psibling number|all type attrName attrValue
(XPointer) psibling
root objVar
(XPointer) root
text
Returns all text node children of that current node combined, i.e. appended into one string.
target
For a processing instruction node the target part is returned. Otherwise an error is generated.
data
For a processing instruction node the data part is returned. Otherwise an error is generated.
prefix
...todo... Returns the namespace prefix.
namespaceURI
...todo... Returns the URI from the namespace of the given node.
namespaceURI
...todo... Returns the localName from the tag name of the given node.
selectNodes xpathQuery typeVar
Returns the result of applying the XPath query xpathQuery to the subtree. This can be a string/value, a list of strings, a list of nodes, a list of attribute name and a list of attribute name / value pairs. If typeVar is given the result type name is store into that variable (empty, bool, number, string, nodes, attrnodes, attrvalues).
set paragraphNodes [$node selectNodes {chapter[3]//para[@type='warning' or @type='error'} ]
foreach paragraph $paragraphNodes {
    lappend  values [$paragraph selectNodes attribute::type]
}
      
getLine
Returns the line number of that node in the orignal parsed XML.
getColumn
Returns the column number of that node in the orignal parsed XML.
asList
Returns the DOM substree starting form the current node as a nested Tcl list.
asXML -indent none/1..8 -channel channelId
...todo... Returns the DOM substree starting form the current node as an indented XML string or sends the output directly to the given channelId in order to save memory.
appendFromList list
Parses list , creates an according DOM subtree and appends this subtree to the current node.
appendFromScript tclScript
...todo... Appends the nodes created in the tclScript by Tcl functions, which have been built using dom createNodeCmd, to the given node.
appendXML XMLstring
Parses XMLstring, creates an according DOM subtree and appends this subtree to the current node.
simpleTranslate outputVar specifications
Translate the subtree starting at the object node according to the specifications in specifications and outputs the result in the variable outputVar . The translation is very similar to Cost Simple mode.
toXPath
...todo... Returns a XPath, which exactly addresses the given node in its document. This XPath is only valid as there are no changes to DOM tree made later one.
xslt
...todo... Applies a XSLT transformation on the whole document of the node object using the XSLT document of the given node. Returns a document object containing the result document of that transformation.
attrName
Returns the value of the attribute attrName. Short cut for getAttribute.

Otherwise, if an unknown method name is given, the command with the same name as the given method within the namespace ::dom::domNode is tried to be executed. This allows quick method additions on Tcl level.

PORTABILITY ISSUES

SEE ALSO

dom, domDoc

KEYWORDS

XML, DOM, document, node, parsing