Class: XMLScan::XPath::DOM::NodeVisitor

Inherits:
Object
  • Object
show all
Defined in:
lib/xml/dom2/xpath.rb

Instance Method Summary collapse

Constructor Details

#initializeNodeVisitor

Returns a new instance of NodeVisitor.



218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/xml/dom2/xpath.rb', line 218

def initialize
  @adapters = Array.new(12, NullNodeAdapter.new)
  @adapters[XML::DOM::Node::ELEMENT_NODE] = ElementNodeAdapter.new
  @adapters[XML::DOM::Node::ATTRIBUTE_NODE] = AttrNodeAdapter.new
  @adapters[XML::DOM::Node::TEXT_NODE] =
    @adapters[XML::DOM::Node::CDATA_SECTION_NODE] = TextNodeAdapter.new
  @adapters[XML::DOM::Node::PROCESSING_INSTRUCTION_NODE] =
    PINodeAdapter.new
  @adapters[XML::DOM::Node::COMMENT_NODE] = CommentNodeAdapter.new
  @adapters[XML::DOM::Node::DOCUMENT_NODE] = RootNodeAdapter.new
  @attr = {}
end

Instance Method Details

#get_attr_parent(node) ⇒ Object



244
245
246
# File 'lib/xml/dom2/xpath.rb', line 244

def get_attr_parent(node)
  @attr[node]
end

#get_attributes(node) ⇒ Object



240
241
242
# File 'lib/xml/dom2/xpath.rb', line 240

def get_attributes(node)
  @attr[node]
end

#regist_attributes(node, attrs) ⇒ Object



235
236
237
238
# File 'lib/xml/dom2/xpath.rb', line 235

def regist_attributes(node, attrs)
  @attr[node] = attrs
  attrs.each { |i| @attr[i] = node }
end

#visit(node) ⇒ Object



231
232
233
# File 'lib/xml/dom2/xpath.rb', line 231

def visit(node)
  @adapters[node.nodeType].wrap(node, self)
end