class RbGCCXML::ParserEventHandler

Our SAX Events handler class

Constants

IGNORE_NODES

Ignore types we don’t handle yet

NESTED_NODES

Some nodes are actually stored in XML as nested structures

Public Instance Methods

end_document() click to toggle source

Once the document is done parsing we process our node tree

# File lib/rbgccxml/sax_parser.rb, line 63
def end_document
  NodeCache.process_tree
end
start_element(name, attributes = []) click to toggle source
# File lib/rbgccxml/sax_parser.rb, line 37
def start_element(name, attributes = [])
  attr_hash = Hash[*attributes.flatten]

  # Need to build a node in memory for those
  # that we don't directly support
  if IGNORE_NODES.include?(name)
    name = "Node"
  end

  node = RbGCCXML.const_get(name).new(attr_hash)

  if NESTED_NODES.include?(name)
    # Don't save node to cache. These nodes don't have
    # ids on which we can index off of
    @context_node.children << node
    node.parent = @context_node
  else
    # Save node to node cache
    NodeCache << node

    # Save node for any XML children it might have later
    @context_node = node
  end
end