Sending multiple emails

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending multiple emails

James Newcombe
I've rebuilt email-form.xpl so that it constructs different emails depending on various conditions in the form. That works nicely, and it's even embedding form information in the emails it creates. I've got to the point where I have created a nicely structured set of <message> structures, as expected by the Orbeon Email processor. They are all wrapped up in a <messages> tag, so I have something like <messages><message>...</message></messages>.

When it comes to actually calling the email processor, I need to work through that XML structure calling the email processor for one message at a time. The code below is what I have to do this and I can see from the debug that it is receiving my messages correctly, but once I check inside the processor all of the XML tags have been stripped away, and the email processor won't accept the input (which I know would only send the first message if it worked at all) because it says it is an incomplete content model.

   
    <p:processor name="oxf:pipeline">
       
        <p:input name="config" href="#messages" transform="oxf:unsafe-xslt" debug="LOOPING THROUGH EMAIL MESSAGES - MESSAGES">
    <p:config xsl:version="2.0">
               
                <p:param type="input" name="messages"/>
                                <xsl:message>
                                        XXXXX
                                        <xsl:value-of select="messages/message" />
                                        XXXXX
                                </xsl:message>
               
                <xsl:for-each select="/*/message">
                        <p:processor name="oxf:email">
                                <p:input name="data">
                                        <message>
                                                <xsl:value-of select="messages/message" />       
                                        </message>
                                </p:input>       
                        </p:processor>
                </xsl:for-each>
           </p:config>
        </p:input>
    </p:processor>

Clearly I did something wrong, but I don't see what it was.
Reply | Threaded
Open this post in threaded view
|

Re: Sending multiple emails

Erik Bruchez
Administrator
James,

(I also sent this privately.)

To print the XML via XSLT, use <xsl:copy-of> instead of <xsl:value-of>. The latter always takes the *string value* of the XML, which only looks at the text nodes. The former makes a copy of the XML tree.

The email processor can only send one email at a time. So What's needed is iterating over the <message> elements you have created via XSLT. The iteration must be done in XPL, so you must use <p:for-each>:

    http://wiki.orbeon.com/forms/doc/developer-guide/xml-pipeline-language-xpl#TOC-p:for-each-element

Regards,

-Erik


Reply | Threaded
Open this post in threaded view
|

Re: Sending multiple emails

James Newcombe
Erik,

I tried wrapping it in a <p:for-each> and that didn't help much either, but I re-wrote the code in a different way, which didn't require nearly so much modification of the standard email-form.xpl. It's working now.

Thanks,
James.
Reply | Threaded
Open this post in threaded view
|

Re: Sending multiple emails

Erik Bruchez
Administrator
James,

Great to hear that it's working!

-Erik