Module: MultiXML::Parser
- Included in:
- MultiXML::Parsers::Libxml, MultiXML::Parsers::LibxmlSax, MultiXML::Parsers::Nokogiri, MultiXML::Parsers::NokogiriSax, MultiXML::Parsers::Oga, MultiXML::Parsers::Ox, MultiXML::Parsers::Rexml
- Defined in:
- lib/multi_xml/parser.rb
Overview
Base module for XML parser implementations
Built-in parsers extend this module and declare the XML library's
native parse-error class as a ParseError constant. The inherited
#parse_error method reads that constant so parse can
wrap backend-specific parse failures uniformly.
Matches the role of MultiJSON::Adapter — a shared contract that
custom parsers can pick up by extending this module, while keeping
backwards compatibility with parsers that instead define a
parse_error method directly.
Instance Method Summary collapse
-
#parse_error ⇒ Class
Return the parse-error class declared on the including parser.
Instance Method Details
#parse_error ⇒ Class
Return the parse-error class declared on the including parser
The lookup uses inherit: false so a stray top-level
::ParseError in the host process (Racc defines one when
Nokogiri is loaded) is correctly ignored.
41 42 43 44 45 |
# File 'lib/multi_xml/parser.rb', line 41 def parse_error const_get(:ParseError, false) rescue NameError raise ParserLoadError, "Parser #{self} must define a ParseError constant" end |