class Xlsxrb::Ooxml::XmlParser::BaseListener
Base listener with unmapped-data collection support.
Attributes
Public Class Methods
Source
# File lib/xlsxrb/ooxml/xml_parser.rb, line 24 def initialize @unmapped_data = [] @unmapped_stack = [] @capturing_unmapped = false @current_unmapped = nil end
Public Instance Methods
Source
# File lib/xlsxrb/ooxml/xml_parser.rb, line 59 def characters(text) return unless @capturing_unmapped && !@unmapped_stack.empty? current = @unmapped_stack.last current[:text] = (current[:text] || "") + text end
# File lib/xlsxrb/ooxml/xml_parser.rb, line 48 def end_element(_uri, _localname, _qname) return unless @capturing_unmapped @unmapped_stack.pop return unless @unmapped_stack.empty? @capturing_unmapped = false @unmapped_data << @current_unmapped @current_unmapped = nil end
# File lib/xlsxrb/ooxml/xml_parser.rb, line 32 def recognized_tag?(_uri, _localname, _qname) false end
Override in subclass: return true if the tag is recognized.
# File lib/xlsxrb/ooxml/xml_parser.rb, line 36 def start_element(uri, localname, qname, attrs) if @capturing_unmapped child = { tag: localname, attrs: attrs.dup, children: [], text: nil } @unmapped_stack.last[:children] << child @unmapped_stack.push(child) elsif !recognized_tag?(uri, localname, qname) @capturing_unmapped = true @current_unmapped = { tag: localname, attrs: attrs.dup, children: [], text: nil } @unmapped_stack.push(@current_unmapped) end end