private int processFile(String filename, String webAppRootPath, IRequestProxy request, CompressorSettings settings,
String pathAddition) {
//System.out.println("pathAddition "+pathAddition);
int errorCount = 0;
TagReader source = null;
try {
source = new TagReader(new FileReader(filename));
} catch (IOException e) {
logger.error("Could not open file", e);
errorCount++;
return errorCount;
}
List<Element> els = source.getAllElements();
for (Element el : els) {
if (el.getName().equals(settings.getTagName())) {
try {
String body = el.getContentAsString();
Attributes attrs = source.parseAttributes(el);
String id = attrs.getValue("id");
String method = attrs.getValue("method");
String options = attrs.getValue("options");
String basepath = attrs.getValue("basepath");
if (body == null) body = "";
if (body.contains("<%--"))
body = removeJspComments(body);
if (body.contains("<%")) {
logger.warn("Dynamic content found, tag skipped in file " + filename);
} else {
CompressTagHandler tagHandler = new CompressTagHandler(id, method, options, basepath);
tagHandler.handleTag(request, null, body);
}
} catch (JSCompileException e) {
errorCount++;
logger.error("Tag process exception:", e);
}
} else if (el.getName().equals("%")) {
Attributes attrs = source.parseAttributes(el);
if (attrs != null && attrs.isValueExists("include") && attrs.isValueExists("file")) {
String file = attrs.getValue("file");
String pa = "";
if (!file.trim().startsWith("/") && file.indexOf("/")>=0)
pa = file.substring(0, file.lastIndexOf("/")+1);