1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
11 # A single input source for an XML entity.
12 module sax
::input_source
14 # A single input source for an XML entity.
16 # This class allows a SAX application to encapsulate information
17 # about an input source in a single object, which may include
18 # a public identifier, a system identifier and a stream (possibly
19 # with a specified encoding).
21 # There are two places that the application can deliver an
22 # input source to the parser: as the argument to the `XMLReader.parse`
23 # method, or as the return value of the `EntityResolver.resolve_entity`
26 # The SAX parser will use the `InputSource` object to determine how to read XML
27 # input. If there is a byte stream, the parser will use that byte stream, using
28 # the encoding specified in the InputSource or else (if no encoding is
29 # specified) autodetecting the character encoding using an algorithm
30 # such as the one in the XML specification. If no byte stream is available, the
31 # parser will attempt to open a URI connection to the resource identified by
32 # the system identifier.
34 # An InputSource object belongs to the application: the SAX parser
35 # shall never modify it in any way (it may modify a copy if
36 # necessary). However, standard processing of the stream is to close it on as
37 # part of end-of-parse cleanup, so applications should not attempt to re-use
38 # such streams after they have been handed to a parser.
40 # Note: The original documentation comes, in part,
41 # from [SAX 2.0](http://www.saxproject.org).
46 # Create a new input source with the specified system identifier.
48 # Applications may use `public_id=` to include a public identifier as well,
49 # or `encoding=` to specify the character encoding, if known.
51 # If the system identifier is a URL, it must be fully resolved (it may not
53 init with_system_id
(system_id
: String) do
54 self.system_id
= system_id
57 # Create a new input source with the specified stream.
59 # Application writers should use `system_id=` to provide a base for
60 # resolving relative URIs, may use `public_id=` to include a public
61 # identifier, and may use `encoding=` to specify the object's character
63 init with_stream
(stream
: IStream) do
67 # The public identifier as a string.
69 # The public identifier is always optional: if the application
70 # writer includes one, it will be provided as part of the
71 # location information.
72 var public_id
: nullable String = null is writable
74 # The system identifier as a string.
76 # If its an URL, it must be fully resolved (it may not be a relative URL).
78 # Applications may set `public_id` to include a
79 # public identifier as well, or set `encoding` to specify
80 # the character encoding, if known.
81 var system_id
: nullable String = null is writable
83 # The stream containing the document.
85 # Application writers should set `system_id` to provide a base
86 # for resolving relative URIs, may set `public_id` to include a
87 # public identifier, and may set `encoding` to specify the object's
89 var stream
: nullable IStream = null is writable
91 # The character encoding, if known.
93 # The encoding must be a string acceptable for an
94 # XML encoding declaration (see section 4.3.3 of the XML 1.0
96 var encoding
: nullable String = null is writable