VelocityEngine ve = VelocityUtil.getEngine();
ve.getTemplate("/" + location + "/" + pageIdent + "." + VELOCITY_HTMLPAGE_EXTENSION).merge(context, sw);
ITextRenderer renderer = new ITextRenderer();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setValidating(false);
DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
builder.setEntityResolver(new DTDResolver());
String s = sw.toString();
s = escapeEspecialCharacter(s);
s = processCSSPath(s, host, "css", "\\(", "\\)", ")", url);
s = processCSSPath(s, host, "css", "\\\"", "\\\"", "\"", url);
Tidy tidy = new Tidy();
tidy.setXHTML(true);
ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
tidy.parse(is, os);
s = os.toString();
is = new ByteArrayInputStream(s.getBytes());
Document doc = builder.parse(is);
NodeList nl = doc.getElementsByTagName("img");
for (int i = 0; i < nl.getLength(); i++) {
Node n = nl.item(i);
Node srcNode = n.getAttributes().getNamedItem("src");