opendap/src/main/java/opendap/dap/parsers/DDSXMLParser.java
public static String normalizeToXML(String s) {

        // Some handy definitons.
        String xmlGT = "&gt;";
        String xmlLT = "&lt;";
        String xmlAmp = "&amp;";
        String xmlApos = "&apos;";
        String xmlQuote = "&quot;";

        boolean Debug = false;
        StringBuilder sb = new StringBuilder(s);

        for (int offset = 0; offset < sb.length(); offset++) {

            char c = sb.charAt(offset);

            switch (c) {

                case '>': // GreaterThan
                    sb.replace(offset, offset + 1, xmlGT);
                    break;

                case '<': // Less Than
                    sb.replace(offset, offset + 1, xmlLT);
                    break;

                case '&': // Ampersand
                    sb.replace(offset, offset + 1, xmlAmp);
                    break;

                case '\'': // Single Quote
                    sb.replace(offset, offset + 1, xmlApos);
                    break;

                case '\"': // Double Quote
                    sb.replace(offset, offset + 1, xmlQuote);
                    break;

                default:
                    break;
            }

        }
        //Coverity[DEADCODE]
        if (Debug) System.out.println("String: `" + s + "` normalized to: `" + sb + "`");

        return (sb.toString());

    }
public static String normalizeToXML(String s) {

        // Some handy definitons.
        String xmlGT = "&gt;";
        String xmlLT = "&lt;";
        String xmlAmp = "&amp;";
        String xmlApos = "&apos;";
        String xmlQuote = "&quot;";

        boolean Debug = false;
        StringBuilder sb = new StringBuilder(s);

        for (int offset = 0; offset < sb.length(); offset++) {

            char c = sb.charAt(offset);

            switch (c) {

                case '>': // GreaterThan
                    sb.replace(offset, offset + 1, xmlGT);
                    break;

                case '<': // Less Than
                    sb.replace(offset, offset + 1, xmlLT);
                    break;

                case '&': // Ampersand
                    sb.replace(offset, offset + 1, xmlAmp);
                    break;

                case '\'': // Single Quote
                    sb.replace(offset, offset + 1, xmlApos);
                    break;

                case '\"': // Double Quote
                    sb.replace(offset, offset + 1, xmlQuote);
                    break;

                default:
                    break;
            }

        }
        //Coverity[DEADCODE]
        if (Debug) System.out.println("String: `" + s + "` normalized to: `" + sb + "`");

        return (sb.toString());

    }
public static String normalizeToXML ( String s ) { // Some handy definitons.
 String xmlGT = "&gt;" ; String xmlLT = "&lt;" ; String xmlAmp = "&amp;" ; String xmlApos = "&apos;" ; String xmlQuote = "&quot;" ; boolean Debug = false ; StringBuilder sb = new StringBuilder ( s ) ; for ( int offset = 0 ; offset < sb . length ( ) ; offset ++ ) { char c = sb . charAt ( offset ) ; switch ( c ) { case ' ' : // GreaterThan
 sb . replace ( offset , offset + 1 , xmlGT ) ; break ; case ' ' : // Less Than
 sb . replace ( offset , offset + 1 , xmlLT ) ; break ; case ' ' : // Ampersand
 sb . replace ( offset , offset + 1 , xmlAmp ) ; break ; case ' ' : // Single Quote
 sb . replace ( offset , offset + 1 , xmlApos ) ; break ; case ' ' : // Double Quote
 sb . replace ( offset , offset + 1 , xmlQuote ) ; break ; default : break ; } } //Coverity[DEADCODE]
 if ( Debug ) System . out . println ( "String: `" + s + "` normalized to: `" + sb + "`" ) ; return ( sb . toString ( ) ) ; }
This method is used to normalize strings prior
to their inclusion in XML documents. XML has certain parsing requirements
around reserved characters. These reserved characters must be replaced with
symbols recognized by the XML parser as place holder for the actual symbol.
<p/>
The rule for this normalization is as follows:
<p/>
<ul>
<li> The &lt; (less than) character is replaced with &amp;lt;
<li> The &gt; (greater than) character is replaced with &amp;gt;
<li> The &amp; (ampersand) character is replaced with &amp;amp;
<li> The ' (apostrophe) character is replaced with &amp;apos;
<li> The &quot; (double quote) character is replaced with &amp;quot;
</ul>

@param s The String to be normalized.
@return The normalized String.
This method is used to normalize strings prior to their inclusion in XML documents . XML has certain parsing requirements around reserved characters . These reserved characters must be replaced with symbols recognized by the XML parser as place holder for the actual symbol . <p / > The rule for this normalization is as follows : <p / > <ul > <li > The &lt ; ( less than ) character is replaced with &amp ; lt ; <li > The &gt ; ( greater than ) character is replaced with &amp ; gt ; <li > The &amp ; ( ampersand ) character is replaced with &amp ; amp ; <li > The ( apostrophe ) character is replaced with &amp ; apos ; <li > The &quot ; ( double quote ) character is replaced with &amp ; quot ; < / ul >