[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: SAX InputSource and character streams

  • From: Rob Lugt <roblugt@e...>
  • To: Mike Brown <mike@s...>, xml-dev@l...
  • Date: Tue, 20 Feb 2001 10:23:27 +0000

sax inputsource
On Monday, February 19, 2001 5:26 PM, Mike Brown wrote:-
> [snip]
> When constructing a SAX InputSource from a character stream
> (java.io.Reader), is it correct to assume that any encoding
> declaration given in the document will be ignored?
>

Mike, I don't think you need to worry about the encoding in this case.
Obviously it is an implementational thing, but I would argue that it makes
no sense for a SAX parser to try to validate the encoding string contained
within a character stream (java.io.Reader).

As you obviously know, the encoding declaration is used to allow the parser
to convert from a Byte stream (java.io.InputStream) into a character stream
(java.io.Reader).  As you are providing a character stream, the parser does
not need to worry about the encoding.  In fact, the parser couldn't do
anything with the encoding even if you wanted it to - because it would need
Bytes to operate on - and you aren't giving it any!

All XML parsers have to do an awkward little dance when reading an external
entity: checking for a Byte Order Mark and xml declaration in order to
determine which encoding the entity uses.  The external entity (byte stream)
is then wrapped by a character stream (java.io.Reader) that understands the
encoding of the byte stream, and the character stream is used from then on.
If the java.io.Reader points back to the start of the external entity (as is
likely), the parser will then get to see the encoding string (in character
form), but it is purely informational at this point and the parser is
unlikely to do anything with it.

Hope this helps
Regards
Rob Lugt
ElCel Technology




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.