Class: Moxml::SAX::Handler
- Inherits:
-
Object
- Object
- Moxml::SAX::Handler
- Defined in:
- lib/moxml/sax/handler.rb
Overview
Abstract base class for SAX event handlers
This class defines the interface for handling SAX parsing events. Subclass this and override the event methods you need to handle.
All event methods have default implementations that do nothing, so you only need to override the events you care about.
Direct Known Subclasses
Instance Method Summary collapse
-
#on_cdata(text) ⇒ void
Called when a CDATA section is encountered.
-
#on_characters(text) ⇒ void
Called when character data is encountered.
-
#on_comment(text) ⇒ void
Called when a comment is encountered.
-
#on_end_document ⇒ void
Called when parsing completes successfully.
-
#on_end_element(name) ⇒ void
Called when a closing tag is encountered.
-
#on_error(error) ⇒ void
Called when a fatal parsing error occurs.
-
#on_processing_instruction(target, data) ⇒ void
Called when a processing instruction is encountered.
-
#on_start_document ⇒ void
Called when parsing begins.
-
#on_start_element(name, attributes = {}, namespaces = {}) ⇒ void
Called when an opening tag is encountered.
-
#on_warning(message) ⇒ void
Called when a non-fatal warning occurs.
Instance Method Details
#on_cdata(text) ⇒ void
This method returns an undefined value.
Called when a CDATA section is encountered
68 69 70 |
# File 'lib/moxml/sax/handler.rb', line 68 def on_cdata(text) # Override in subclass if needed end |
#on_characters(text) ⇒ void
This method returns an undefined value.
Called when character data is encountered
Note: This may be called multiple times for a single text node if the parser breaks it into chunks. Concatenate if needed.
60 61 62 |
# File 'lib/moxml/sax/handler.rb', line 60 def on_characters(text) # Override in subclass if needed end |
#on_comment(text) ⇒ void
This method returns an undefined value.
Called when a comment is encountered
76 77 78 |
# File 'lib/moxml/sax/handler.rb', line 76 def on_comment(text) # Override in subclass if needed end |
#on_end_document ⇒ void
This method returns an undefined value.
Called when parsing completes successfully
31 32 33 |
# File 'lib/moxml/sax/handler.rb', line 31 def on_end_document # Override in subclass if needed end |
#on_end_element(name) ⇒ void
This method returns an undefined value.
Called when a closing tag is encountered
49 50 51 |
# File 'lib/moxml/sax/handler.rb', line 49 def on_end_element(name) # Override in subclass if needed end |
#on_error(error) ⇒ void
This method returns an undefined value.
Called when a fatal parsing error occurs
Default implementation raises the error. Override to handle errors differently.
97 98 99 |
# File 'lib/moxml/sax/handler.rb', line 97 def on_error(error) raise error end |
#on_processing_instruction(target, data) ⇒ void
This method returns an undefined value.
Called when a processing instruction is encountered
85 86 87 |
# File 'lib/moxml/sax/handler.rb', line 85 def on_processing_instruction(target, data) # Override in subclass if needed end |
#on_start_document ⇒ void
This method returns an undefined value.
Called when parsing begins
24 25 26 |
# File 'lib/moxml/sax/handler.rb', line 24 def on_start_document # Override in subclass if needed end |
#on_start_element(name, attributes = {}, namespaces = {}) ⇒ void
This method returns an undefined value.
Called when an opening tag is encountered
41 42 43 |
# File 'lib/moxml/sax/handler.rb', line 41 def on_start_element(name, attributes = {}, namespaces = {}) # Override in subclass if needed end |
#on_warning(message) ⇒ void
This method returns an undefined value.
Called when a non-fatal warning occurs
Default implementation ignores warnings. Override to handle warnings (e.g., log them).
108 109 110 |
# File 'lib/moxml/sax/handler.rb', line 108 def on_warning() # Override in subclass if needed end |