The application can use this method to instruct the XML reader to begin parsing an XML document from any valid input source (a byte stream or an URI).
Applications may not invoke this method while a parse is in
progress (they should create a new XMLReader
instead for each
nested XML document). Once a parse is complete, an
application may reuse the same XMLReader
object, possibly with a
different input source.
During the parse, the XMLReader
will provide information
about the XML document through the registered event
handlers.
This method is synchronous: it will not return until parsing has ended. If a client application wants to terminate parsing early, it should throw an exception.
Parameters:
source
: input source for the top-level of the XML document.
# Parse an XML document.
#
# The application can use this method to instruct the XML
# reader to begin parsing an XML document from any valid input
# source (a byte stream or an URI).
#
# Applications may not invoke this method while a parse is in
# progress (they should create a new `XMLReader` instead for each
# nested XML document). Once a parse is complete, an
# application may reuse the same `XMLReader` object, possibly with a
# different input source.
#
# During the parse, the `XMLReader` will provide information
# about the XML document through the registered event
# handlers.
#
# This method is synchronous: it will not return until parsing
# has ended. If a client application wants to terminate
# parsing early, it should throw an exception.
#
# Parameters:
#
# * `source`: input source for the top-level of the XML document.
fun parse(input: InputSource) is abstract
lib/sax/xml_reader.nit:247,2--270,42
redef fun parse(input) do
var system_id: nullable MaybeError[String, Error] = null
model.locator = new SAXLocatorImpl
if input.system_id != null then
system_id = resolve_system_id(input.system_id.as(not null))
if system_id.is_error then
model.fire_warning(system_id.error.message, system_id.error)
else
model.locator.system_id = system_id.value
end
end
model.locator.public_id = input.public_id
# TODO: encoding
if input.stream != null then
lexer = new XophonLexer(model, input.stream.as(not null))
parse_main
else if system_id != null then
if system_id.is_error then
model.fire_fatal_error("File <{input.system_id.as(not null)}> not found.", null)
else
lexer = new XophonLexer(model,
new FileReader.open(system_id.value))
parse_main
lexer.close
end
else
model.fire_fatal_error("At least a stream or a system identifier must be specified. None given.",
null)
end
end
lib/saxophonit/saxophonit.nit:127,2--158,4
redef fun parse(input) do
setup_parse
parent.parse(input)
end
lib/sax/helpers/xml_filter_impl.nit:214,2--217,4
redef fun parse(input) do
assert parent_is_not_null: parent != 0 else
sys.stderr.write("No parent for filter.")
end
if parent.feature_writable(decl_handler_uri) then
parent.property(decl_handler_uri) = self
end
if parent.feature_writable(lexical_handler_uri) then
parent.property(lexical_handler_uri) = self
end
super
end
lib/saxophonit/testing.nit:299,2--310,4