Class: ChupaText::SAXParser::Document
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- ChupaText::SAXParser::Document
- Defined in:
- lib/chupa-text/sax-parser.rb
Instance Method Summary collapse
-
#cdata_block(content) ⇒ Object
-
#characters(text) ⇒ Object
-
#end_element_namespace(name, prefix = nil, uri = nil) ⇒ Object
-
#error(detail) ⇒ Object
-
#initialize(listener) ⇒ Document
constructor
A new instance of Document.
-
#start_element_namespace(name, attributes = [], prefix = nil, uri = nil, namespaces = []) ⇒ Object
Constructor Details
#initialize(listener) ⇒ Document
Returns a new instance of Document.
60 61 62 63 |
# File 'lib/chupa-text/sax-parser.rb', line 60 def initialize(listener) @listener = listener @namespaces_stack = [] end |
Instance Method Details
#cdata_block(content) ⇒ Object
97 98 99 |
# File 'lib/chupa-text/sax-parser.rb', line 97 def cdata_block(content) @listener.cdata(content) end |
#characters(text) ⇒ Object
93 94 95 |
# File 'lib/chupa-text/sax-parser.rb', line 93 def characters(text) @listener.characters(text) end |
#end_element_namespace(name, prefix = nil, uri = nil) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/chupa-text/sax-parser.rb', line 85 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) ⇒ Object
101 102 103 |
# File 'lib/chupa-text/sax-parser.rb', line 101 def error(detail) raise ParseError, detail end |
#start_element_namespace(name, attributes = [], prefix = nil, uri = nil, namespaces = []) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/chupa-text/sax-parser.rb', line 65 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 |