users@jaxb.java.net

Re: CDATA in marshalling output?

From: J. Medina <jmedina_at_on.com>
Date: Fri, 04 Apr 2003 09:32:55 +0200

CDATA is used mainly required when you want to include some the text may
contain some xml-like content or some characters that may be confused with
xml tags. For example, the following is incorrect:

      <script>
            echo Usage:
            echo program.exe <server> <username>
      </script>

 Of course, in the case above the '<' and '>' can be escaped using &lt; and
 &gt; , and as long as the JAXB classes make the conversion back and forth
 there is no problem (Currently JAXB does this conversion, so I can live
 with it).

 But, for human readers, is better to have something like:
      <script>
            <[[CDATA
            echo Usage:
            echo program.exe <server> <username>
            ]]>
      </script>

 instead of:

      <script>
            echo Usage:
            echo program.exe &lt; server &gt; &lt; username &gt;
      </script>