}
void loadTemplates (InputStream inputStream, final String templateName) {
final SAXBuilder parser = new SAXBuilder();
try {
TemplateSettings templateSettings = TemplateSettings.getInstance();
Document doc = parser.build(inputStream);
Element root = doc.getRootElement();
for (Object element : root.getChildren()) {
if (element instanceof Element) {
final Template template = readExternal((Element) element, templateName);
final String key = template.getKey();
// Only add if not present
if (key != null && templateSettings.getTemplate(key) == null) {
templateSettings.addTemplate(template);
}
}
}
} catch (Exception e) {
e.printStackTrace();