Class: MultiXML::Parsers::LibxmlSax::Handler Private
- Inherits:
-
Object
- Object
- MultiXML::Parsers::LibxmlSax::Handler
- Includes:
- LibXML::XML::SaxParser::Callbacks, SaxHandler
- Defined in:
- lib/multi_xml/parsers/libxml_sax.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
LibXML SAX handler.
libxml-ruby's namespace-aware callback strips prefixes from the attrs
hash, so we rely on the qname-preserving on_start_element callback
and resolve namespaces via SaxHandler's scope stack.
Instance Attribute Summary
Attributes included from SaxHandler
Instance Method Summary collapse
-
#initialize(mode) ⇒ Handler
constructor
private
Create a new SAX handler.
-
#on_end_document ⇒ void
private
Handle end of document (no-op).
-
#on_end_element(_name) ⇒ void
private
Handle end of an element.
-
#on_error(_error) ⇒ void
private
Handle parse errors (no-op; libxml-ruby raises directly).
-
#on_start_document ⇒ void
private
Handle start of document (no-op).
-
#on_start_element(name, attrs = {}) ⇒ void
private
Handle start of an element.
Methods included from SaxHandler
Constructor Details
#initialize(mode) ⇒ Handler
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new SAX handler
110 111 112 |
# File 'lib/multi_xml/parsers/libxml_sax.rb', line 110 def initialize(mode) initialize_handler(mode) end |
Instance Method Details
#on_end_document ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Handle end of document (no-op)
125 126 |
# File 'lib/multi_xml/parsers/libxml_sax.rb', line 125 def on_end_document end |
#on_end_element(_name) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Handle end of an element
162 163 164 |
# File 'lib/multi_xml/parsers/libxml_sax.rb', line 162 def on_end_element(_name) handle_end_element end |
#on_error(_error) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Handle parse errors (no-op; libxml-ruby raises directly)
133 134 |
# File 'lib/multi_xml/parsers/libxml_sax.rb', line 133 def on_error(_error) end |
#on_start_document ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Handle start of document (no-op)
118 119 |
# File 'lib/multi_xml/parsers/libxml_sax.rb', line 118 def on_start_document end |
#on_start_element(name, attrs = {}) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Handle start of an element
libxml-ruby strips xmlns declarations from attrs and passes through prefixed names for regular attributes. Since libxml_sax only uses this handler in :strip mode, we route through the namespace-aware entrypoint with empty ns_decls and treat attribute qnames as-if they had no namespace — matching the desired :strip output.
148 149 150 151 152 153 154 155 |
# File 'lib/multi_xml/parsers/libxml_sax.rb', line 148 def on_start_element(name, attrs = {}) prefix, local = sax_split_qname(name.to_s) tuples = attrs.map do |k, v| ap, al = sax_split_qname(k.to_s) [ap, al, v] end handle_start_element_ns(local, prefix, tuples, []) end |