return templateRegistryDescriptor;
}
public static MailTemplate parseMailTemplate(Element element, Parse parse) {
MailTemplate mailTemplate = new MailTemplate();
mailTemplate.setLanguage(XmlUtil.attribute(element, "language"));
mailTemplate.setFrom(parseRecipientTemplate(element, "from", parse));
mailTemplate.setTo(parseRecipientTemplate(element, "to", parse));
mailTemplate.setCc(parseRecipientTemplate(element, "cc", parse));
mailTemplate.setBcc(parseRecipientTemplate(element, "bcc", parse));
Element subjectElement = XmlUtil.element(element, "subject");
if (subjectElement != null) {
mailTemplate.setSubject(XmlUtil.getContentText(subjectElement));
}
Element textElement = XmlUtil.element(element, "text");
if (textElement != null) {
mailTemplate.setText(XmlUtil.getContentText(textElement));
}
Element htmlElement = XmlUtil.element(element, "html");
if (htmlElement != null) {
// extract child nodes from html element
DocumentFragment fragment = htmlElement.getOwnerDocument().createDocumentFragment();
for (Node child = htmlElement.getFirstChild(), next; child != null; child = next) {
next = child.getNextSibling();
fragment.appendChild(child);
}
mailTemplate.setHtml(XmlUtil.toString(fragment));
}
// attachments
Element attachmentsElement = XmlUtil.element(element, "attachments");
if (attachmentsElement != null) {
for (Element attachmentElement : XmlUtil.elements(attachmentsElement, "attachment")) {
AttachmentTemplate attachmentTemplate = new AttachmentTemplate();
mailTemplate.addAttachmentTemplate(attachmentTemplate);
attachmentTemplate.setUrl(XmlUtil.attribute(attachmentElement, "url"));
attachmentTemplate.setResource(XmlUtil.attribute(attachmentElement, "resource"));
attachmentTemplate.setFile(XmlUtil.attribute(attachmentElement, "file"));
}