240563dafdcb85f7bef73f58cacabf406dbcaedf
1 LOG
.inform("XMLDOC.DomReader loaded");
3 XMLDOC
.DomReader
= function(root
) {
8 * The current node the reader is on
13 * Get the current node the reader is on
14 * @type XMLDOC.Parser.node
16 XMLDOC
.DomReader
.prototype.getNode
= function() {
21 * Set the node the reader should be positioned on.
22 * @param node {XMLDOC.Parser.node}
24 XMLDOC
.DomReader
.prototype.setNode
= function(node
) {
29 * A helper method to make sure the current node will
30 * never return null, unless null is passed as the root.
31 * @param step {String} An expression to evaluate - should return a node or null
33 XMLDOC
.DomReader
.prototype.navigate
= function(step
) {
35 if ((n
= step
) != null)
44 * Get the root node of the current node's document.
46 XMLDOC
.DomReader
.prototype.root
= function() {
47 this.navigate(this.dom
);
51 * Get the parent of the current node.
53 XMLDOC
.DomReader
.prototype.parent
= function() {
54 return this.navigate(this.node
.parentNode());
58 * Get the first child of the current node.
60 XMLDOC
.DomReader
.prototype.firstChild
= function() {
61 return this.navigate(this.node
.firstChild());
65 * Get the last child of the current node.
67 XMLDOC
.DomReader
.prototype.lastChild
= function() {
68 return this.navigate(this.node
.lastChild());
72 * Get the next sibling of the current node.
74 XMLDOC
.DomReader
.prototype.nextSibling
= function() {
75 return this.navigate(this.node
.nextSibling());
79 * Get the previous sibling of the current node.
81 XMLDOC
.DomReader
.prototype.prevSibling
= function() {
82 return this.navigate(this.node
.prevSibling());
85 //===============================================================================================
89 * Walk the tree starting with the current node, calling the plug-in for
90 * each node visited. Each time the plug-in is called, the DomReader
91 * is passed as the only parameter. Use the {@link XMLDOC.DomReader#getNode} method
92 * to access the current node. <i>This method uses a depth first traversal pattern.</i>
94 * @param srcFile {String} The source file being evaluated
96 XMLDOC
.DomReader
.prototype.getSymbols
= function(srcFile
)
98 XMLDOC
.DomReader
.symbols
= [];
99 XMLDOC
.DomReader
.currentFile
= srcFile
;
100 JSDOC
.Symbol
.srcFile
= (srcFile
|| "");
102 if (defined(JSDOC
.PluginManager
)) {
103 JSDOC
.PluginManager
.run("onDomGetSymbols", this);
106 return XMLDOC
.DomReader
.symbols
;
110 * Find the node with the given name using a depth first traversal.
111 * Does not modify the DomReader's current node.
113 * @param name {String} The name of the node to find
114 * @return the node that was found, or null if not found
116 XMLDOC
.DomReader
.prototype.findNode
= function(name
)
120 // Start at the current node and move into the subtree,
121 // looking for the node with the given name
122 function deeper(node
, find
)
127 if (node
.name
== find
)
132 if (node
.firstChild())
134 look
= deeper(node
.firstChild(), find
);
137 if (!look
&& node
.nextSibling())
139 look
= deeper(node
.nextSibling(), find
);
146 return deeper(this.getNode().firstChild(), name
);
150 * Find the next node with the given name using a depth first traversal.
152 * @param name {String} The name of the node to find
154 XMLDOC
.DomReader
.prototype.findPreviousNode
= function(name
)