Templates template;
try {
template = pool.getTemplate(templatesURL);
if (template == null) {
final StreamSource source = new StreamSource(new URL(templatesURL).toExternalForm());
template = tFactory.newTemplates(source);
pool.addTemplate(templatesURL, template);
}
// Find out about the content type and encoding.