Class: XSD::XMLParser::XMLScanner
- Inherits:
-
Parser
show all
- Includes:
- XMLScan::Visitor
- Defined in:
- lib/xsd/xmlparser/xmlscanner.rb
Constant Summary
collapse
- ENTITY_REF_MAP =
{
'lt' => '<',
'gt' => '>',
'amp' => '&',
'quot' => '"',
'apos' => '\''
}
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
#do_parse(string_or_readable) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 20
def do_parse(string_or_readable)
@attrs = {}
@curattr = nil
@scanner = XMLScan::XMLScanner.new(self)
@scanner.kcode = XSD::Charset.charset_str(charset) if charset
@scanner.parse(string_or_readable)
end
|
#on_attr_charref(code) ⇒ Object
125
126
127
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 125
def on_attr_charref(code)
@curattr << [code].pack('U')
end
|
#on_attr_charref_hex(code) ⇒ Object
129
130
131
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 129
def on_attr_charref_hex(code)
on_attr_charref(code)
end
|
#on_attr_entityref(ref) ⇒ Object
121
122
123
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 121
def on_attr_entityref(ref)
@curattr << ENTITY_REF_MAP[ref]
end
|
#on_attr_value(str) ⇒ Object
117
118
119
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 117
def on_attr_value(str)
@curattr << str
end
|
#on_attribute(name) ⇒ Object
113
114
115
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 113
def on_attribute(name)
@attrs[name] = @curattr = ''
end
|
#on_cdata(str) ⇒ Object
85
86
87
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 85
def on_cdata(str)
characters(str)
end
|
#on_chardata(str) ⇒ Object
def on_pi(target, pi); end
81
82
83
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 81
def on_chardata(str)
characters(str)
end
|
#on_charref(code) ⇒ Object
97
98
99
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 97
def on_charref(code)
characters([code].pack('U'))
end
|
#on_charref_hex(code) ⇒ Object
101
102
103
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 101
def on_charref_hex(code)
on_charref(code)
end
|
#on_entityref(ref) ⇒ Object
93
94
95
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 93
def on_entityref(ref)
characters(ENTITY_REF_MAP[ref])
end
|
#on_etag(name) ⇒ Object
89
90
91
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 89
def on_etag(name)
end_element(name)
end
|
#on_stag(name) ⇒ Object
109
110
111
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 109
def on_stag(name)
@attrs = {}
end
|
#on_stag_end(name) ⇒ Object
140
141
142
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 140
def on_stag_end(name)
start_element(name, @attrs)
end
|
#on_stag_end_empty(name) ⇒ Object
def on_attribute_end(name); end
135
136
137
138
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 135
def on_stag_end_empty(name)
on_stag_end(name)
on_etag(name)
end
|
#on_xmldecl_encoding(str) ⇒ Object
63
64
65
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 63
def on_xmldecl_encoding(str)
self.scanner_kcode = str
end
|
#on_xmldecl_version(str) ⇒ Object
59
60
61
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 59
def on_xmldecl_version(str)
end
|
#parse_error(msg) ⇒ Object
41
42
43
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 41
def parse_error(msg)
raise ParseError.new(msg)
end
|
#scanner_kcode=(charset) ⇒ Object
28
29
30
31
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 28
def scanner_kcode=(charset)
@scanner.kcode = XSD::Charset.charset_str(charset) if charset
self.xmldecl_encoding = charset
end
|
#valid_error(msg) ⇒ Object
49
50
51
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 49
def valid_error(msg)
raise NotValidError.new(msg)
end
|
#warning(msg) ⇒ Object
53
54
55
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 53
def warning(msg)
warn(msg)
end
|
45
46
47
|
# File 'lib/xsd/xmlparser/xmlscanner.rb', line 45
def wellformed_error(msg)
raise NotWellFormedError.new(msg)
end
|