Class: XSD::XMLParser::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/xsd/xmlparser/parser.rb

Defined Under Namespace

Classes: ElementConstraintError, FormatDecodeError, ParseError, ParserError, UnexpectedElementError, UnknownAttributeError, UnknownElementError

Constant Summary collapse

@@parser_factory =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, opt = {}) ⇒ Parser

Returns a new instance of Parser.



51
52
53
54
# File 'lib/xsd/xmlparser/parser.rb', line 51

def initialize(host, opt = {})
  @host = host
  @charset = opt[:charset] || nil
end

Instance Attribute Details

#charsetObject

Returns the value of attribute charset.



49
50
51
# File 'lib/xsd/xmlparser/parser.rb', line 49

def charset
  @charset
end

Class Method Details

.add_factory(factory) ⇒ Object



40
41
42
43
44
45
# File 'lib/xsd/xmlparser/parser.rb', line 40

def self.add_factory(factory)
  if $DEBUG
    puts "Set #{ factory } as XML processor."
  end
  @@parser_factory = factory
end

.create_parser(host, opt = {}) ⇒ Object



33
34
35
36
37
38
# File 'lib/xsd/xmlparser/parser.rb', line 33

def self.create_parser(host, opt = {})
  unless @@parser_factory
    raise ParserError.new("illegal XML parser configuration")
  end
  @@parser_factory.new(host, opt)
end

.factoryObject



29
30
31
# File 'lib/xsd/xmlparser/parser.rb', line 29

def self.factory
  @@parser_factory
end

Instance Method Details

#parse(string_or_readable) ⇒ Object



56
57
58
59
60
61
# File 'lib/xsd/xmlparser/parser.rb', line 56

def parse(string_or_readable)
  @textbuf = ''
  prologue
  do_parse(string_or_readable)
  epilogue
end