title: Why does XMLEventReader report a CHARACTERS event that contains markup?
body: <p>I have an XMLEventReader.  It has been built from an XMLInputFactory with the "UTF8" encoding.  I am using it to read an XML file whose "encoding" attribute is set to "UTF-8".</p>
  
  <p>I have verified that the XML file views correctly under Firefox.  When you view the page encoding, it says that it is UTF-8.</p>
  
  <p>I have set the XMLEventReader to coalesce character events like this:</p>
  
  <pre><code>reader.setProperty(XMLEventReader.IS_COALESCING, Boolean.TRUE);
  </code></pre>
  
  <p>The XML document does not have a DTD.  It is valid.</p>
  
  <p>The XMLEventReader will occasionally report that a CHARACTERS event has been received whose content is (minus the quotation marks), for example:</p>
  
  <pre><code>r problems were most severe and frequent.) Did you sleep a lot more than usual nearly every night during that period?&lt;/text&gt;  Ð 
  </code></pre>
  
  <p>Note the presence of the markup tag near the end of the sample, as well as the capital thorn.  Note also that the sentence has been lopped off; presumably there was another CHARACTERS event before this one that contains the leading part of the sentence.</p>
  
  <p>Why does the XMLEventReader screw up the parsing?  Why are the characters not displaying correctly?  Why does the XMLEventReader not coalesce CHARACTERS events, if that's what's going on?  Why is StAX so unbelievably festeringly ugly and unpredictable?</p>
  
  <p>I am using the XMLEventReader supplied to me by my Java runtime (Java 6) on a Mac.</p>
  
  <p>Here is some sample XML, which of course I've simply copied from my editor, so who knows what character conversions occurred as a result of that, but anyhow:</p>
  
  <pre><code>&lt;question id="BMHPD17"&gt;
    &lt;permittedResponseCount&gt;1&lt;/permittedResponseCount&gt;
    &lt;text&gt;It’s hard for me to stay out of trouble. (Would you say this is true or false for you?)&lt;/text&gt;
    &lt;namedAnswerSet idref="TrueFalse"&gt;&lt;/namedAnswerSet&gt;
  &lt;/question&gt;
  </code></pre>
  
  <p>Note the "smart apostrophe" on line 3.</p>
  
  <p>I am reading this by reacting to a CHARACTERS event, saving its contents to a String on the stack, then reacting to an END_ELEMENT event whose name is "question".  Upon receiving the END_ELEMENT event for question, I retrieve the value of the String I just mentioned, and construct a Java object that takes the string I just mentioned as input.</p>
  
  <p>When I System.out.println() the result, I get (sometimes) the bogus junk I referred to earlier.</p>
  
  <p>When I wrap System.out inside a PrintWriter with "UTF8" encoding set, so that I'm not simply outputting characters according to the platform's encoding, I get the same results.</p>