Class: XSD::XMLParser::OxParser
Instance Attribute Summary
Attributes inherited from Parser
#charset
Instance Method Summary
collapse
Methods inherited from Parser
add_factory, create_parser, factory, #initialize, #parse
Instance Method Details
#attr(key, val) ⇒ Object
83
84
85
86
87
88
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 83
def attr(key,val)
return if @element_stack[-1].nil?
attr_hash = @element_stack[-1]
attr_hash[key.to_s] = val
end
|
#attrs_done ⇒ Object
90
91
92
93
94
95
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 90
def attrs_done
attr_hash = @element_stack[-1]
name = @element_stack[-2]
base_start_element(name, attr_hash) unless attr_hash.nil?
end
|
#base_end_element ⇒ Object
43
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 43
alias_method :base_end_element, :end_element
|
#base_start_element ⇒ Object
36
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 36
alias_method :base_start_element, :start_element
|
60
61
62
63
64
65
66
67
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 60
def cdata(t)
@decoder.nil? ? characters(t) : characters(@decoder.decode(t))
end
|
69
70
71
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 69
def (t)
@decoder.nil? ? characters(t) : characters(@decoder.decode(t))
end
|
#do_parse(string_or_readable) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 16
def do_parse(string_or_readable)
@element_stack = []
begin
require 'htmlentities' @decoder = ::HTMLEntities.new(:expanded)
rescue LoadError
@decoder = nil
end
string = string_or_readable.respond_to?(:read) ? string_or_readable.read : StringIO.new(string_or_readable)
if @decoder.nil?
::Ox.sax_parse(self, string, {:symbolize=> false, :convert_special=> true, :skip=> :skip_return} )
else
::Ox.sax_parse(self, string, {})
end
end
|
#end_element(n) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 44
def end_element(n)
if @element_stack[-2].to_s == n.to_s
attr_hash = @element_stack.pop
attr_key = @element_stack.pop
else
$stderr.puts "!!!! OxParser.end_element FAILED TO FIND STACK PAIR [#{n}] IN STACK [#{PP.pp(@element_stack,'')}]"
end
base_end_element(n.to_s)
end
|
#end_instruct(n) ⇒ Object
78
79
80
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 78
def end_instruct(n)
end
|
#instruct(n) ⇒ Object
74
75
76
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 74
def instruct(n)
end
|
#start_element(n) ⇒ Object
37
38
39
40
41
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 37
def start_element(n)
@element_stack.push n.to_s @element_stack.push Hash.new
end
|
56
57
58
|
# File 'lib/xsd/xmlparser/oxparser.rb', line 56
def text(t)
@decoder.nil? ? characters(t) : characters(@decoder.decode(t))
end
|