Class: XSD::XMLParser::XMLParser
- Defined in:
- lib/xsd/xmlparser/xmlparser.rb
Defined Under Namespace
Classes: Listener
Instance Attribute Summary
Attributes inherited from Parser
Instance Method Summary collapse
Methods inherited from Parser
add_factory, create_parser, factory, #initialize, #parse
Constructor Details
This class inherits a constructor from XSD::XMLParser::Parser
Instance Method Details
#do_parse(string_or_readable) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/xsd/xmlparser/xmlparser.rb', line 27 def do_parse(string_or_readable) # XMLParser passes a String in utf-8. @charset = 'utf-8' @parser = Listener.new @parser.parse(string_or_readable) do |type, name, data| case type when XML::Parser::START_ELEM start_element(name, data) when XML::Parser::END_ELEM end_element(name) when XML::Parser::CDATA characters(data) else raise FormatDecodeError.new("Unexpected XML: #{ type }/#{ name }/#{ data }.") end end end |