xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Clark <an...@apache.org>
Subject Re: is it possible to overide default encoding for DOMParser
Date Wed, 24 Jan 2001 02:07:04 GMT
ThomasB wrote:
> Is it possible to change that default expectation of the 
> DOMParser; such that I do not have to hack the xml document 
> with an encoding attribute?

In theory, if the document is converted to EBCDIC, then the
XMLDecl of your document should be updated to reflect the
new encoding. In reality, there is a way to make the parser
ignore the encoding. Read on...

If you *know* the real encoding of the document, simply
use a standard java.io.InputStreamReader with the EBCDIC
encoding and wrap that in an org.xml.sax.InputSource
object to pass to the parse() method on the parser. For
example:

  InputStream stream = new FileInputStream("document.xml");
  Reader reader = new InputStreamReader(stream, "EBCDIC");
  InputSource source = new InputSource(reader);
  parser.parse(source);

Since you're explicitly doing the conversion, the parser
will ignore the encoding specified in the XML document.

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org

Mime
View raw message