public static String escapeXml(String originalString) {
    	
    	if ( null == originalString ) {
    		return "" ;
    	}
    	
        int start = 0;
        int length = originalString.length();
        char[] arrayBuffer = originalString.toCharArray();
        StringBuffer escapedStringBuffer = null;

        for (int i = 0; i < length; i++) {
            char c = arrayBuffer[i];
            if (c <= HIGHEST_SPECIAL) {
                char[] escaped = xmlRepresentation[c];
                if (escaped != null) {
                    // new StringBuffer to build the xml string
                    if (start == 0) {
                        escapedStringBuffer = new StringBuffer(length + 5);
                    }
                    // add unescaped portion
                    if (start < i) {
                        escapedStringBuffer.append(arrayBuffer,start,i-start);
                    }
                    start = i + 1;
                    // add escaped xml
                    escapedStringBuffer.append(escaped);
                }
            }
        }
        // escaping not required
        if (start == 0) {
            return originalString;
        }
        // add rest of unescaped portion
        if (start < length) {
            escapedStringBuffer.append(arrayBuffer,start,length-start);
        }
        return escapedStringBuffer.toString();
    }