class ChupaText::SAXParser::Document
Public Class Methods
new(listener)
click to toggle source
# File lib/chupa-text/sax-parser.rb, line 59 def initialize(listener) @listener = listener @namespaces_stack = [] end
Public Instance Methods
cdata_block(content)
click to toggle source
# File lib/chupa-text/sax-parser.rb, line 96 def cdata_block(content) @listener.cdata(content) end
characters(text)
click to toggle source
# File lib/chupa-text/sax-parser.rb, line 92 def characters(text) @listener.characters(text) end
end_element_namespace(name, prefix=nil, uri=nil)
click to toggle source
# File lib/chupa-text/sax-parser.rb, line 84 def end_element_namespace(name, prefix=nil, uri=nil) @listener.end_element(uri, name, build_qname(prefix, name)) namespaces = @namespaces_stack.pop namespaces.each do |namespace_prefix, _| @listener.end_prefix_mapping(namespace_prefix) end end
error(detail)
click to toggle source
# File lib/chupa-text/sax-parser.rb, line 100 def error(detail) raise ParseError, detail end
start_element_namespace(name, attributes=[], prefix=nil, uri=nil, namespaces=[])
click to toggle source
# File lib/chupa-text/sax-parser.rb, line 64 def start_element_namespace(name, attributes=[], prefix=nil, uri=nil, namespaces=[]) namespaces.each do |namespace_prefix, namespace_uri| @listener.start_prefix_mapping(namespace_prefix, namespace_uri) end attributes_hash = {} attributes.each do |attribute| attribute_qname = build_qname(attribute.prefix, attribute.localname) attributes_hash[attribute_qname] = attribute.value end @namespaces_stack.push(namespaces) @listener.start_element(uri, name, build_qname(prefix, name), attributes_hash) end
Private Instance Methods
build_qname(prefix, local_name)
click to toggle source
# File lib/chupa-text/sax-parser.rb, line 105 def build_qname(prefix, local_name) if prefix "#{prefix}:#{local_name}" else local_name end end