src/main/java/org/jboss/util/xml/DOMWriter.java
public static String normalize(String s, boolean canonical)
   {
      StringBuffer str = new StringBuffer();

      int len = (s != null) ? s.length() : 0;
      for (int i = 0; i < len; i++)
      {
         char ch = s.charAt(i);
         switch (ch)
         {
            case '<':
            {
               str.append("&lt;");
               break;
            }
            case '>':
            {
               str.append("&gt;");
               break;
            }
            case '&':
            {
               str.append("&amp;");
               break;
            }
            case '"':
            {
               str.append("&quot;");
               break;
            }
            case '\'':
            {
               str.append("&apos;");
               break;
            }
            case '\r':
            case '\n':
            {
               if (canonical)
               {
                  str.append("&#");
                  str.append(Integer.toString(ch));
                  str.append(';');
                  break;
               }
               // else, default append char
            }
            default:
            {
               str.append(ch);
            }
         }
      }
      return (str.toString());
   }
public static String normalize(String s, boolean canonical)
   {
      StringBuffer str = new StringBuffer();

      int len = (s != null) ? s.length() : 0;
      for (int i = 0; i < len; i++)
      {
         char ch = s.charAt(i);
         switch (ch)
         {
            case '<':
            {
               str.append("&lt;");
               break;
            }
            case '>':
            {
               str.append("&gt;");
               break;
            }
            case '&':
            {
               str.append("&amp;");
               break;
            }
            case '"':
            {
               str.append("&quot;");
               break;
            }
            case '\'':
            {
               str.append("&apos;");
               break;
            }
            case '\r':
            case '\n':
            {
               if (canonical)
               {
                  str.append("&#");
                  str.append(Integer.toString(ch));
                  str.append(';');
                  break;
               }
               // else, default append char
            }
            default:
            {
               str.append(ch);
            }
         }
      }
      return (str.toString());
   }
public static String normalize ( String s , boolean canonical ) { StringBuffer str = new StringBuffer ( ) ; int len = ( s != null ) ? s . length ( ) : 0 ; for ( int i = 0 ; i < len ; i ++ ) { char ch = s . charAt ( i ) ; switch ( ch ) { case ' ' : { str . append ( "&lt;" ) ; break ; } case ' ' : { str . append ( "&gt;" ) ; break ; } case ' ' : { str . append ( "&amp;" ) ; break ; } case ' ' : { str . append ( "&quot;" ) ; break ; } case ' ' : { str . append ( "&apos;" ) ; break ; } case ' ' : case ' ' : { if ( canonical ) { str . append ( "&#" ) ; str . append ( Integer . toString ( ch ) ) ; str . append ( ' ' ) ; break ; } // else, default append char } default : { str . append ( ch ) ; } } } return ( str . toString ( ) ) ; }
Normalizes the given string.
Normalizes the given string .