// time and memory. We should be reading chunks and reporting chunks instead
// of reading characters individually and reporting all the characters in
// one callback. Also, currently we don't provide any locator information:
// line number, column number, etc... so if we report an error it will appear
// as if the invalid XML character was in the include parent. -- mrglavas
XMLStringBuffer buffer = new XMLStringBuffer();
fReader = getReader(fSource);
int ch;
while((ch = fReader.read()) != -1) {
if (isValid(ch)) {
buffer.append((char)ch);
}
else if (XMLChar.isHighSurrogate(ch)) {
int ch2 = fReader.read();
if (XMLChar.isLowSurrogate(ch2)) {
// convert surrogates to a supplemental character
int sup = XMLChar.supplemental((char)ch, (char)ch2);
// supplemental character must be a valid XML character
if (!isValid(sup)) {
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"InvalidCharInContent",
new Object[] { Integer.toString(sup, 16) },
XMLErrorReporter.SEVERITY_FATAL_ERROR);
continue;
}
buffer.append((char) ch);
buffer.append((char) ch2);
}
else {
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"InvalidCharInContent",
new Object[] { Integer.toString(ch, 16) },