5
## Oct 23, 1998 yoshidam Fix each
18
== Module XML::DOM (XML::SimpleTree)
24
== Class XML::DOM::Visitor
26
Skelton class of Visitor.
28
You can override the following methods and implement the other
31
You should implement some "visit_name_NAME" methods and
32
"method_missing" method for accept_name.
37
## You can override the following methods and implement the other
38
## "visit_TYPE" methods.
39
## You should implement some "visit_name_NAME" methods and
40
## "method_missing" method for accept_name.
45
--- Visitor#visit_Document(grove, *rest)
49
def visit_Document(grove, *rest)
50
grove.children_accept(self, *rest)
54
--- Visitor#visit_Element(element, *rest)
58
def visit_Element(element, *rest)
59
element.children_accept(self, *rest)
63
--- Visitor#visit_Text(text, *rest)
67
def visit_Text(text, *rest)
71
--- Visitor#visit_CDATASection(text, *rest)
75
def visit_CDATASection(text, *rest)
79
--- Visitor#visit_Comment(comment, *rest)
83
def visit_Comment(comment, *rest)
87
--- Visitor#visit_ProcessingInstruction(pi, *rest)
91
def visit_ProcessingInstruction(pi, *rest)
98
== Class XML::DOM::Node
100
XML::Grove::Visitor like interfaces.
105
--- Node#accept(visitor, *rest)
107
call back visit_* method.
109
## XML::Grove::Visitor like interfaces
110
def accept(visitor, *rest)
111
typename = self.class.to_s.sub(/.*?([^:]+)$/, '\1')
112
visitor.send("visit_" + typename, self, *rest)
116
--- Node#accept_name(visitor, *rest)
118
call back visit_name_* method.
120
def accept_name(visitor, *rest)
121
if nodeType == ELEMENT_NODE
122
name_method = "visit_name_" + nodeName
123
visitor.send(name_method, self, *rest)
125
self.accept(visitor, *rest)
130
--- Node#children_accept(visitor, *rest)
132
for each children, call back visit_* methods.
134
def children_accept(visitor, *rest)
136
@children && @children.each { |node|
137
ret.push(node.accept(visitor, *rest))
143
--- Node#children_accept_name(visitor, *rest)
145
for each children, call back visit_name_* method.
147
def children_accept_name(visitor, *rest)
149
@children && @children.each { |node|
150
ret.push(node.accept_name(visitor, *rest))
160
## Iterator interface
166
if siblings.length == 0
167
break if sibstack.length == 0
168
siblings = sibstack.pop
171
node = siblings.shift
173
children = node.childNodes
175
sibstack.push(siblings)
176
siblings = children.to_a.dup