*/
public static NodeInfo makeDoc(String href, String baseURI, XPathContext c, SourceLocator locator)
throws XPathException {
Configuration config = c.getConfiguration();
// If the href contains a fragment identifier, strip it out now
//System.err.println("Entering makeDoc " + href);
int hash = href.indexOf('#');
String fragmentId = null;
if (hash>=0) {
if (hash==href.length()-1) {
// # sign at end - just ignore it
href = href.substring(0, hash);
} else {
fragmentId = href.substring(hash+1);
href = href.substring(0, hash);
if (!NameChecker.isValidNCName(fragmentId)) {
XPathException de = new XPathException("The fragment identifier " + Err.wrap(fragmentId) + " is not a valid NCName");
de.setErrorCode("XTRE1160");
de.setXPathContext(c);
throw de;
}
}
}
Controller controller = c.getController();
// Resolve relative URI
DocumentURI documentKey = computeDocumentKey(href, baseURI);
// see if the document is already loaded
DocumentInfo doc = config.getGlobalDocumentPool().find(documentKey);
if (doc != null) {
return doc;
}
DocumentPool pool = controller.getDocumentPool();
doc = pool.find(documentKey);
if (doc != null) {
return getFragment(doc, fragmentId, c);
}
// check that the document was not written by this transformation
if (!controller.checkUniqueOutputDestination(documentKey)) {
pool.markUnavailable(documentKey);
XPathException err = new XPathException(
"Cannot read a document that was written during the same transformation: " + documentKey);
err.setXPathContext(c);
err.setErrorCode("XTRE1500");
throw err;
}
try {
if (pool.isMarkedUnavailable(documentKey)) {
XPathException err = new XPathException(
"Document has been marked not available: " + documentKey);
err.setXPathContext(c);
err.setErrorCode("FODC0002");
throw err;
}
DocumentInfo newdoc = config.buildDocument(documentKey.toString());
controller.registerDocument(newdoc, documentKey);
controller.addUnavailableOutputDestination(documentKey);
return getFragment(newdoc, fragmentId, c);
} catch (XPathException err) {