title: JAXB - Marshalling a single quote character code
body: <p>I'm using JAXB to generate XML that is uploaded to our Google feed. While testing and comparing this new method's output to the output from the old way that we were doing it (Using JSPs), I noticed that single quote characters aren't being handled correctly.</p>
  
  <p>Field Content:</p>
  
  <pre><code>&amp; ' " &gt; &lt;
  </code></pre>
  
  <p>Old Correct output: </p>
  
  <pre><code>&lt;title&gt; &amp;amp; &amp;#39; &amp;quot; &amp;gt; &amp;lt; &lt;/title&gt;
  </code></pre>
  
  <p>New Incorrect output:</p>
  
  <pre><code>&lt;title&gt; &amp;amp; ' &amp;quot; &amp;gt; &amp;lt; &lt;/title&gt;
  </code></pre>
  
  <p>I tried replacing all single quote characters in the field with</p>
  
  <pre><code>&amp;#39
  </code></pre>
  
  <p>before I marshall the XML, but this ends up replacing the ampersand with its character code as well as leaving me with a useless #39 sitting there after marshalling.</p>
  
  <p>At which point should I try to remedy this problem? Can I get the correct behavior by altering the string in some way before passing it into the JAXB class, or is there something I must do to change how the marshalling handles single quotes?</p>
  
  <p>Thanks for reading!</p>
  
  <p>EDIT:
  Sorry I wasn't more clear before, Google's documentation requires that those 5 characters are represented either by their Entity or Character Codes.</p>
  
  <p>From their documentation:</p>
  
  <p>Data values that are not in CDATA sections, including URLs, must use escape codes for the characters listed in the
  following table. You can use either the entity code or the character code to represent these special characters.</p>
  
  <pre><code>Ampersand &amp; &amp;amp; &amp;#38;
  Single Quote ' &amp;apos; &amp;#39;
  Double Quote " &amp;quot; &amp;#34;
  Greater Than &gt; &amp;gt; &amp;#62;
  Less Than &lt; &amp;lt; &amp;#60;
  </code></pre>
  
  <p>I would like to avoid the CDATA route if possible.</p>