{
public static final String DATA_TEMPLATE= "data-template";
public Template createTemplate(Element fromElement, String aTemplateName)
{
Template template= createTemplate(aTemplateName);
template.setFiringEvents(false);
Element mainElement= fromElement;
String attributeValue= fromElement.getAttribute(DATA_TEMPLATE);
if (attributeValue.equals(""))
mainElement= (Element) getTemplateElements(fromElement, aTemplateName, false).get(0);
List<Element> subTemplates= getTemplateElements(mainElement, ".+", false);
for (int i= 0; i < subTemplates.size(); i++)
{
Element childTemplateElement= subTemplates.get(i);
String childTemplateName= childTemplateElement.getAttribute(DATA_TEMPLATE);
template.addChild(this.createTemplate(childTemplateElement, childTemplateName));
}
template.setContent(new ContentImpl<Element>(mainElement));
template.setInner(mainElement.getAttribute(DATA_TEMPLATE).indexOf("*") != -1);
//mainElement.removeAttribute(DATA_TEMPLATE);
mainElement.setAttribute(DATA_TEMPLATE, "replaced: " + aTemplateName);
template.setFiringEvents(true);
return template;
}