/** * Checks if the given string contains any invalid XML characters. * * @param value string to be checked * @return <code>true</code> if the string contains invalid XML characters, * <code>false</code> otherwise */ private boolean isInvalid(String value) { char[] ch = value.toCharArray(); int i = 0; while (i < ch.length) { int c = Character.codePointAt(ch, i); if (isInvalid(c)) { return true; } i = i + Character.charCount(c); } return false; }
@Override public void startElement( String uri, String localName, String name, Attributes atts) throws SAXException { // TODO: enable this, but some parsers currently // trip it //assert verifyStartElement(name); // Look for any invalid characters in attribute values. for (int i = 0; i < atts.getLength(); i++) { if (isInvalid(atts.getValue(i))) { // Found an invalid character, so need to filter the attributes AttributesImpl filtered = new AttributesImpl(); for (int j = 0; j < atts.getLength(); j++) { String value = atts.getValue(j); if (j >= i && isInvalid(value)) { // Filter the attribute value when needed Output buffer = new StringOutput(); filter(value.toCharArray(), 0, value.length(), buffer); value = buffer.toString(); } filtered.addAttribute( atts.getURI(j), atts.getLocalName(j), atts.getQName(j), atts.getType(j), value); } atts = filtered; break; } } super.startElement(uri, localName, name, atts); }
int j = i + Character.charCount(c); if (isInvalid(c)) {
/** * Checks if the given string contains any invalid XML characters. * * @param value string to be checked * @return <code>true</code> if the string contains invalid XML characters, * <code>false</code> otherwise */ private boolean isInvalid(String value) { char[] ch = value.toCharArray(); int i = 0; while (i < ch.length) { int c = Character.codePointAt(ch, i); if (isInvalid(c)) { return true; } i = i + Character.charCount(c); } return false; }
/** * Checks if the given string contains any invalid XML characters. * * @param value string to be checked * @return <code>true</code> if the string contains invalid XML characters, * <code>false</code> otherwise */ private boolean isInvalid(String value) { char[] ch = value.toCharArray(); int i = 0; while (i < ch.length) { int c = Character.codePointAt(ch, i); if (isInvalid(c)) { return true; } i = i + Character.charCount(c); } return false; }
@Override public void startElement( String uri, String localName, String name, Attributes atts) throws SAXException { // TODO: enable this, but some parsers currently // trip it //assert verifyStartElement(name); // Look for any invalid characters in attribute values. for (int i = 0; i < atts.getLength(); i++) { if (isInvalid(atts.getValue(i))) { // Found an invalid character, so need to filter the attributes AttributesImpl filtered = new AttributesImpl(); for (int j = 0; j < atts.getLength(); j++) { String value = atts.getValue(j); if (j >= i && isInvalid(value)) { // Filter the attribute value when needed Output buffer = new StringOutput(); filter(value.toCharArray(), 0, value.length(), buffer); value = buffer.toString(); } filtered.addAttribute( atts.getURI(j), atts.getLocalName(j), atts.getQName(j), atts.getType(j), value); } atts = filtered; break; } } super.startElement(uri, localName, name, atts); }
@Override public void startElement( String uri, String localName, String name, Attributes atts) throws SAXException { // TODO: enable this, but some parsers currently // trip it //assert verifyStartElement(name); // Look for any invalid characters in attribute values. for (int i = 0; i < atts.getLength(); i++) { if (isInvalid(atts.getValue(i))) { // Found an invalid character, so need to filter the attributes AttributesImpl filtered = new AttributesImpl(); for (int j = 0; j < atts.getLength(); j++) { String value = atts.getValue(j); if (j >= i && isInvalid(value)) { // Filter the attribute value when needed Output buffer = new StringOutput(); filter(value.toCharArray(), 0, value.length(), buffer); value = buffer.toString(); } filtered.addAttribute( atts.getURI(j), atts.getLocalName(j), atts.getQName(j), atts.getType(j), value); } atts = filtered; break; } } super.startElement(uri, localName, name, atts); }
int j = i + Character.charCount(c); if (isInvalid(c)) {
int j = i + Character.charCount(c); if (isInvalid(c)) {