From: Alister P. <gsp...@gm...> - 2014-08-20 12:30:35
|
Hi all, I would appreciate some advice. I’m trying to write a mail:get-messages() function. mail:get-messages($folder, $messageNumbers) I was hoping to put the contents of multipart messages (e.g. text, html, other binary forms) into an xml result (either as text, xhtml or base64binary), but I’m finding it hard to do. The alternative is to follow the compression:unzip approach and get the user to supply a function to handle the content. I should be able to copy the AbstractExtractFunction.processCompressedEntry method. mail:get-messages($folder, $filterFunction, $storeFunction) Are there any downsides to that approach (other than it being harder to construct for the XQuery user)? …. This is what I wanted to do - but can’t find simple methods of adding those content types to the XML result: // for each BodyPart bp and bp.getContentType() builder.startElement(new QName("body", MailModule.NAMESPACE_URI, MailModule.PREFIX), null); builder.addAttribute(new QName("type", null, null), String.valueOf(contentType)); if (contentType.contains("text/plain")) { // if TEXT store as Characters builder.characters(bp.getContent().toString()); } else if (contentType.contains("text/html")) { // XHTML builder.?ADD?( ModuleUtils.htmlToXHtml(context, "alternative", new StreamSource(bp.getInputStream()), null, null)); } else { // otherwise store as base64Binary add base64 data somehow } builder.endElement(); Regards, Alister |