/** print text data */ protected void printXMLChar( int ch) throws IOException { if (ch == '\r') { printHex(ch); } else if ( ch == '<') { _printer.printText("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '>'){ // character sequence "]]>" can't appear in content, therefore // we should escape '>' _printer.printText(">"); } else if ( ch == '\n' || ch == '\t' || ( ch >= ' ' && _encodingInfo.isPrintable((char)ch))) { _printer.printText((char)ch); } else { printHex(ch); } }
/** print text data */ protected void printXMLChar( int ch) throws IOException { if (ch == '\r') { printHex(ch); } else if ( ch == '<') { _printer.printText("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '>'){ // character sequence "]]>" can't appear in content, therefore // we should escape '>' _printer.printText(">"); } else if ( ch == '\n' || ch == '\t' || ( ch >= ' ' && _encodingInfo.isPrintable((char)ch))) { _printer.printText((char)ch); } else { printHex(ch); } }
protected void printEscaped(String source) throws IOException { int length = source.length(); for (int i = 0; i < length; ++i) { int ch = source.charAt(i); if (!XMLChar.isValid(ch)) { if (++i < length) { surrogates(ch, source.charAt(i)); } else { fatalError("The character '" + (char) ch + "' is an invalid XML character"); } continue; } // escape NL, CR, TAB if (ch == '\n' || ch == '\r' || ch == '\t') { printHex(ch); } else if (ch == '<') { _printer.printText("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '"') { _printer.printText("""); } else if ((ch >= ' ' && _encodingInfo.isPrintable((char) ch))) { _printer.printText((char) ch); } else { printHex(ch); } } }
protected void printEscaped(String source) throws IOException { int length = source.length(); for (int i = 0; i < length; ++i) { int ch = source.charAt(i); if (!XMLChar.isValid(ch)) { if (++i < length) { surrogates(ch, source.charAt(i)); } else { fatalError("The character '" + (char) ch + "' is an invalid XML character"); } continue; } // escape NL, CR, TAB if (ch == '\n' || ch == '\r' || ch == '\t') { printHex(ch); } else if (ch == '<') { _printer.printText("<"); } else if (ch == '&') { _printer.printText("&"); } else if (ch == '"') { _printer.printText("""); } else if ((ch >= ' ' && _encodingInfo.isPrintable((char) ch))) { _printer.printText((char) ch); } else { printHex(ch); } } }