![]() |
| Sending messages to programs with XSLT prosessor The xsl message handler is a package that opens a channel for the XSLT processor output. package MyMessage::Send;
use strict;
sub message_handler {
my ($msg,$params)=@_;
open my $fh, "|/usr/lib/sendmail -oi -t" or die "could not open";
#print some headers
#print message
$msg->print_html($fh);#or print_xml or print_text
#html, xml or text state for the print method of XSLT
# or use the print method of XSL stylesheet
XSLT::printResultTree($fh,$msg);
#get text data of $msg XML tree
$msgstr=$msg->string();
close($fh);
}
1;The stylesheet can now use the xsl:message element to send the message. <xsl:message msg-handler="MyMessage::Send" To="Destination <{xpath expression}>"
From="User Mail <me@host>"
Subject="subject line">
template for $msg
</xsl:message>
The variable $params is a reference to hash of xsl:message attributes. The attribute values are first evaluated by the XSLT processor as attribute templates except values of msg-handler and terminate. |