SourceResolver resolver = null;
Source source = null;
try {
NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "not", "message");
Document doc = helper.getDocument();
NamespaceHelper i18nHelper = new NamespaceHelper(I18nTransformer.I18N_NAMESPACE_URI,
"i18n", doc);
Element docElement = doc.getDocumentElement();
Element subjectElement = helper.createElement("subject");
docElement.appendChild(subjectElement);
Element i18nTranslateSubjectElement = i18nHelper.createElement("translate");
subjectElement.appendChild(i18nTranslateSubjectElement);
Element subjectI18nElement = i18nHelper.createElement("text", message.getSubject());
i18nTranslateSubjectElement.appendChild(subjectI18nElement);
String[] subjectParams = message.getSubjectParameters();
for (int i = 0; i < subjectParams.length; i++) {
Element paramElement = i18nHelper.createElement("param", subjectParams[i]);
i18nTranslateSubjectElement.appendChild(paramElement);
}
Element bodyElement = helper.createElement("body");
docElement.appendChild(bodyElement);
Element i18nTranslateElement = i18nHelper.createElement("translate");
bodyElement.appendChild(i18nTranslateElement);
Element bodyI18nElement = i18nHelper.createElement("text", message.getBody());
i18nTranslateElement.appendChild(bodyI18nElement);
String[] msgParams = message.getBodyParameters();
for (int i = 0; i < msgParams.length; i++) {
Element paramElement = i18nHelper.createElement("param", msgParams[i]);
i18nTranslateElement.appendChild(paramElement);
}
Session session = this.request.getSession();
session.setAttribute("notification.dom", doc);
resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
source = resolver.resolveURI("cocoon://modules/notification/message/" + locale, null,
null);
if (source.exists()) {
doc = DocumentHelper.readDocument(source.getInputStream());
helper = new NamespaceHelper(NAMESPACE, "not", doc);
subjectElement = helper.getFirstChild(doc.getDocumentElement(), "subject");
String subject = DocumentHelper.getSimpleElementText(subjectElement);
bodyElement = helper.getFirstChild(doc.getDocumentElement(), "body");