Java Code Examples for org.apache.xerces.util.XMLChar#isValid()
The following examples show how to use
org.apache.xerces.util.XMLChar#isValid() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DmozParser.java From anthelion with Apache License 2.0 | 6 votes |
public int read(char[] cbuf, int off, int len) throws IOException { int n = in.read(cbuf, off, len); if (n != -1) { for (int i = 0; i < n; i++) { char c = cbuf[off+i]; char value = c; if (!(XMLChar.isValid(c))) // fix invalid characters value = 'X'; else if (lastBad && c == '<') { // fix mis-matched brackets if (i != n-1 && cbuf[off+i+1] != '/') value = 'X'; } lastBad = (c == 65533); cbuf[off+i] = value; } } return n; }
Example 2
Source File: DmozParser.java From nutch-htmlunit with Apache License 2.0 | 6 votes |
public int read(char[] cbuf, int off, int len) throws IOException { int n = in.read(cbuf, off, len); if (n != -1) { for (int i = 0; i < n; i++) { char c = cbuf[off+i]; char value = c; if (!(XMLChar.isValid(c))) // fix invalid characters value = 'X'; else if (lastBad && c == '<') { // fix mis-matched brackets if (i != n-1 && cbuf[off+i+1] != '/') value = 'X'; } lastBad = (c == 65533); cbuf[off+i] = value; } } return n; }
Example 3
Source File: DmozParser.java From anthelion with Apache License 2.0 | 5 votes |
public int read() throws IOException { int c = in.read(); int value = c; if (c != -1 && !(XMLChar.isValid(c))) // fix invalid characters value = 'X'; else if (lastBad && c == '<') { // fix mis-matched brackets in.mark(1); if (in.read() != '/') value = 'X'; in.reset(); } lastBad = (c == 65533); return value; }
Example 4
Source File: AsyncXMLReader.java From jlibs with Apache License 2.0 | 5 votes |
void charReference(Chars data) throws SAXException{ int cp = Integer.parseInt(data.toString(), radix); if(XMLChar.isValid(cp)){ if(valueStarted) value.appendCodePoint(cp); else if(contentHandler!=null){ char chars[] = Character.toChars(cp); contentHandler.characters(chars, 0, chars.length); } }else throw fatalError("invalid xml character"); }
Example 5
Source File: DmozParser.java From nutch-htmlunit with Apache License 2.0 | 5 votes |
public int read() throws IOException { int c = in.read(); int value = c; if (c != -1 && !(XMLChar.isValid(c))) // fix invalid characters value = 'X'; else if (lastBad && c == '<') { // fix mis-matched brackets in.mark(1); if (in.read() != '/') value = 'X'; in.reset(); } lastBad = (c == 65533); return value; }