public Resource doFilter(ResourceMatchResult filterMatchResult, Set<ResourceLoadingOption> options,
ResourceFilterChain chain) throws ResourceNotFoundException {
String resourceName = filterMatchResult.getResourceName();
String xsltName = filterMatchResult.substitute(xslt);
Resource xsltRes;
try {
xsltRes = resourceLoadingService.getResource(xsltName);
} catch (ResourceNotFoundException e) {
xsltRes = null;
}
if (xsltRes == null && failIfNotFound) {
throw new ResourceNotFoundException("Could not find XSLT file for " + this + ", resourceName="
+ filterMatchResult.getResourceName());
}
Resource resource = chain.doFilter(filterMatchResult, options);
resource = transformDocument(resource, resourceName, xsltRes, xsltName);
if (getSaveToDir() != null) {
resource = saveToDir(resource, resourceName);