| java.lang.Object uk.org.ponder.xml.XMLDecoder
XMLDecoder | public class XMLDecoder (Code) | | The XMLDecoder is used to provide a more instrumented decoding facility for
parsing XML files. The Sun default UTF-8 decoder supplies inaccurate location
information for invalid characters, provides minimal UTF-8 validation and
minimal description of decoding errors. XMLDecoder does the work of parsing
an XML declaration in a small repertoire of encodings, and hands off the
task of character conversion for the rest of the stream to the
org.ponder.streamutil.DirectInputStreamReader if the declaration
is consistent with the UTF-8 encoding scheme.
|
stripDeclaration | public static XMLDecoderReturn stripDeclaration(InputStream is, EncodingErrorHandler handler) throws IOException(Code) | | Strips off the declaration from an XML file, and returns information suitable
for further processing. The declaration is decoded to infer the encoding scheme
as far as possible, and the return value includes the number of bytes decoded,
the declaration as a String, and a Reader from which the decoded contents of the
rest of the file may be read.
This decoder currently detects UCS16 both little and big-endian using the BOM
(Byte Order Mark) 0xffef invented by the Evil Empire, and 8-bit
encodings for which the JVM includes a converter with a name matching the XML
declaration version. Files without an encoding declaration which appear to be
8-bit are interpreted as UTF-8 (as per XML specification).
Parameters: is - An inputstream containing an XML file. Parameters: handler - An EncodingErrorHandler to which errors encountered during UTF-8decoding may be reported. An XMLDecoderReturn object providing the client with everything requiredto continue parsing the XML file. |
|
|