private void printEscaped ( String s , boolean isAttributeValue ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; switch ( c ) { case ' ' : out . print ( "&lt;" ) ; break ; case ' ' : out . print ( "&gt;" ) ; break ; case ' ' : out . print ( "&amp;" ) ; break ; case ' ' : if ( isAttributeValue && quote . equals ( "'" ) ) out . print ( "&apos;" ) ; else out . print ( c ) ; break ; case ' ' : if ( isAttributeValue && quote . equals ( "\"" ) ) out . print ( "&quot;" ) ; else out . print ( c ) ; break ; case ' ' : if ( isAttributeValue ) out . print ( "&#10;" ) ; else out . print ( c ) ; break ; case ' ' : if ( isAttributeValue ) out . print ( "&#13;" ) ; else out . print ( c ) ; break ; default : out . print ( c ) ; } } }
we could always escape if we wanted to .