EscapeURI.checkPercentEncoding(absoluteURI.toString());
Reader reader = context.getController().getUnparsedTextURIResolver().resolve(absoluteURI, encoding, config);
try {
FastStringBuffer sb = new FastStringBuffer(2048);
char[] buffer = new char[2048];
boolean first = true;
int actual;
int line = 1;
int column = 1;
while (true) {
actual = reader.read(buffer, 0, 2048);
if (actual < 0) {
break;
}
for (int c=0; c<actual;) {
int ch32 = buffer[c++];
if (ch32 == '\n') {
line++;
column = 0;
}
column++;
if (UTF16.isHighSurrogate(ch32)) {
if (c==actual) {
actual = reader.read(buffer, 0, 2048);
c = 0;
}
char low = buffer[c++];
ch32 = UTF16.combinePair((char)ch32, low);
}
if (!checker.isValidChar(ch32)) {
XPathException err = new XPathException("The unparsed-text file contains a character illegal in XML (line=" +
line + " column=" + column + " value=hex " + Integer.toHexString(ch32) + ')');
err.setErrorCode("XTDE1190");
throw err;
}
}
if (first) {
first = false;
if (buffer[0]=='\ufeff') {
// don't include the BOM in the result
sb.append(buffer, 1, actual-1);
} else {
sb.append(buffer, 0, actual);
}
} else {
sb.append(buffer, 0, actual);
}
}
reader.close();
return sb.condense();
} catch (java.io.UnsupportedEncodingException encErr) {
XPathException e = new XPathException("Unknown encoding " + Err.wrap(encoding), encErr);
e.setErrorCode("XTDE1190");
throw e;
} catch (java.io.IOException ioErr) {