return resolveTemplate(uri, null);
}
public StartDocument resolveTemplate(String uri, Locator location) throws SAXParseException, ProcessingException {
Source input = null;
StartDocument doc = null;
SourceResolver resolver = null;
try {
resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
input = resolver.resolveURI(uri);
SourceValidity validity = null;
String storeUri = JX_STORE_PREFIX + input.getURI();
doc = (StartDocument) getStore().get(storeUri);
// TODO: why was this previously in synchronized( getCache() )?
if (doc != null) {
boolean recompile = false;
if (doc.getSourceValidity() == null) {
recompile = true;
} else {
int valid = doc.getSourceValidity().isValid();
if (valid == SourceValidity.UNKNOWN) {
validity = input.getValidity();
valid = doc.getSourceValidity().isValid(validity);
}
if (valid != SourceValidity.VALID) {
recompile = true;
}
}
if (recompile) {
doc = null; // recompile
}
}
if (doc == null) {
Parser parser = new Parser(new ParsingContext(this.stringTemplateParser, this.instructionFactory));
// call getValidity before using the stream is faster if
// the source is a SitemapSource
if (validity == null) {
validity = input.getValidity();
}
SourceUtil.parse(manager, input, parser);
doc = parser.getStartEvent();
doc.setUri(input.getURI());
doc.setSourceValidity(validity);
getStore().store(storeUri, doc);
}
} catch (SourceException se) {
throw SourceUtil.handle("Error during resolving of '" + uri + "'.", se);