Want plain text in email body

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

Want plain text in email body

sachin
Hello,

I have been quite successful creating conditional Form elements and sending an email.
The send email contains an xml and pdf attachment of the filled out form. But I want to send form data in plain text within the email body instead of attached pdf and xml.
How this can be done.

Any suggestion into the right direction would be very much appreciated.Thanks in advance.

Regards,
Sachin
Reply | Threaded
Open this post in threaded view
|

Re: Want plain text in email body

Alessandro  Vernet
Administrator
Hi Sachin,

Are you saying that you'd like to inline specific form field values inside the text of the email? This would be covered by the following RFE (link below). Is this inline with what you have in mind?

https://github.com/orbeon/orbeon-forms/issues/2428

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Want plain text in email body

sachin
This post was updated on .
Hello,

We have tried to send plain text email and tried by editing the:

1)Properties-local-prod.xml :-

<property as="xs:boolean" name="oxf.fr.email.attach-pdf.*.*" value="false" />
<property as="xs:boolean" name="oxf.fr.email.attach-xml.*.*" value="false" />


2)WEB-INF\resources\apps\fr\print\xhtml2txt2:-

<xsl:template match="/">
        <config>
           
                       
            <template href="input:template" show-grid="false"/>
            <xsl:for-each select="//*[@id = 'fr-form-group']//*[p:classes(.) = ($control-classes, 'xbl-component') ]">

                <xsl:variable name="control" select="."/>
                                       
                                        <xsl:variable name="new-line1" select="$control" />
                                        <xsl:text>----KK----</xsl:text>
                                        <xsl:value-of select="$new-line1" />
                                               
                <xsl:variable
                    name="text-field-name"
                    select="frf:buildPDFFieldNameFromHTML($control)"/>

                <xsl:if test="$text-field-name">

                    <xsl:variable name="classes" select="p:classes(.)"/>
                                       
                                        <xsl:text>--NN--</xsl:text>




PLAIN TEXT EMAIL is coming like this:-

----KK----Untitled SectionnamehhhAS_NRO1234emailext-sachin.khera@elisa.fidateThursday May 19, 2016senderxyz@xyz.fi--NN------KK----namehhhAS_NRO1234emailext-sachin.khera@xyz.fidateThursday May 19, 2016senderxyz@xyz.fi----KK----namehhh--NN------KK----AS_NRO1234--NN------KK----emailext-sachin.khera@elisa.fi--NN------KK----dateThursday May 19, 2016--NN------KK----senderxyz@xyz.fi--NN--
 

This is not coming in proper format.How to make it in proper format.Thankyou in advance.

Regards,
Sachin
Reply | Threaded
Open this post in threaded view
|

Re: Want plain text in email body

Alessandro  Vernet
Administrator
Hi Sachin,

There must be more to it, isn't it? What is the file fr\print\xhtml2txt2 you're referring to? (Is the extension missing in the file name?) How is this file called? I imagine it must be referenced from somewhere?

Also, I'm not sure to understand what the problem is. You're saying that the email doesn't come in the "proper format". What do you mean by "proper format"?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Want plain text in email body

sachin
This post was updated on .
Hi,

Yes xhtml2txt2.xsl is referenced form print-text.xpl and print-text.xpl is referenced from text-view.xpl.

1) This xhtml2txt2.xsl is refrenced in orbeon\WEB-INF\resources\apps\fr\print\print-text.xpl :-

<?xml version="1.0" encoding="utf-8"?>
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:oxf="http://www.orbeon.com/oxf/processors"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:ev="http://www.w3.org/2001/xml-events">

   
    <p:param type="input" name="xforms"/>
   
    <p:param type="input" name="parameters"/>
   
    <p:param type="output" name="data"/>

   
    <p:processor name="oxf:pipeline">
        <p:input name="config" href="/ops/pfc/xforms-epilogue.xpl"/>
        <p:input name="data" href="#xforms"/>
        <p:input name="model-data"><null xsi:nil="true"/></p:input>
        <p:input name="instance" href="#parameters"/>
        <p:output name="xformed-data" id="xformed-data"/>
    </p:processor>

    <p:processor name="oxf:request">
        <p:input name="config">
            <config><include>/request/container-namespace</include></config>
        </p:input>
        <p:output name="data" id="request"/>
    </p:processor>

   
    <p:processor name="oxf:xslt">
        <p:input name="config">
            <xsl:transform version="2.0">
                <xsl:import href="oxf:/oxf/xslt/utils/copy.xsl"/>
               
                <xsl:template match="@id">
                    <xsl:attribute name="id" select="substring-after(., doc('input:request')/*/container-namespace)"/>
                </xsl:template>
               
                <xsl:template match="*:script | *:noscript"/>
               
                <xsl:template match="*:form">
                    <xsl:copy>
                        <xsl:attribute name="class" select="string-join(tokenize(@class, '\s+')[. != 'xforms-initially-hidden'], ' ')"/>
                        <xsl:apply-templates select="@* except @class | node()"/>
                    </xsl:copy>
                </xsl:template>
               
                <xsl:template match="*">
                    <xsl:element name="{local-name()}">
                        <xsl:apply-templates select="@* | node()"/>
                    </xsl:element>
                </xsl:template>
            </xsl:transform>
        </p:input>
        <p:input name="data" href="#xformed-data"/>
        <p:input name="request" href="#request"/>
        <p:output name="data" id="xhtml-data"/>
    </p:processor>
       

   
    <p:processor name="oxf:unsafe-xslt">
        <p:input name="data" href="#xhtml-data"/>
        <p:input name="config" href="xhtml2text.xsl"/>
        <p:output name="data" id="text-output"/>
    </p:processor>

    <p:processor name="oxf:text-serializer">
      <p:input name="config">
        <config>
          <content-type>text/plain</content-type>
        </config>
      </p:input>
      <p:input name="data" href="#text-output"/>
      <p:output name="data" ref="data"/>
    </p:processor>



</p:config>


2)print-text.xpl is used in orbeon\WEB-INF\resources\apps\fr\text-view.xpl:-  



<?xml version="1.0" encoding="utf-8"?>

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:oxf="http://www.orbeon.com/oxf/processors"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary">

   
    <p:param type="input" name="instance"/>
   
    <p:param type="input" name="data"/>
   
    <p:param type="output" name="data"/>

   
    <p:processor name="oxf:pipeline">
        <p:input name="config" href="../unroll-form.xpl"/>
        <p:input name="instance" href="#instance"/>
        <p:input name="data" href="#data"/>
        <p:output name="data" id="unrolled-form"/>
    </p:processor>

    <p:processor name="oxf:pipeline">
      <p:input name="config" href="print-text.xpl"/>
      <p:input name="xforms" href="#unrolled-form"/>
      <p:input name="parameters" href="#instance"/>
      <p:output name="data" ref="data"/>
    </p:processor>

</p:config>




Basically we want to send form data in plain text within the email body instead of attached pdf and xml. And in previous message i already shown you the xhtml2text2.xsl file that will print the form data in plan text .
 But data is not coming in proper format in email(as I already shown you email body in previous message),  but we want form data in following format:-


Form name
---------------------

section name-1
-------------------
field1

field2


section name 2
--------------------
field1



Can you please suggest what changes i have to do and in which file we have to do changes. so that i can get plain text data in above format in email body.

and one more thing can you please tell in what form(ex:- in xml or in xhtml), form data passes in text-view.xpl.

Please help us to solve this issue and thankyou in advance.

Regards,
Sachin
Reply | Threaded
Open this post in threaded view
|

Re: Want plain text in email body

emailtoakash
To add what Sachin has mentioned here, Those files are old actually.
But We need to get the form data. Some ideas would be helpful.

Here is our text-view.xpl

<?xml version="1.0" encoding="utf-8"?>

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:oxf="http://www.orbeon.com/oxf/processors"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary">

   
    <p:param type="input" name="instance"/>
   
    <p:param type="input" name="data"/>
   
    <p:param type="output" name="data"/>

   
    <p:processor name="oxf:pipeline">
        <p:input name="config" href="../unroll-form.xpl"/>
        <p:input name="instance" href="#instance"/>
        <p:input name="data" href="#data"/>
        <p:output name="data" id="unrolled-form"/>
    </p:processor>

    <p:processor name="oxf:pipeline">
      <p:input name="config" href="<b>print-text.xpl"/>
      <p:input name="xforms" href="#unrolled-form"/>
      <p:input name="parameters" href="#instance"/>
      <p:output name="data" ref="data"/>
    </p:processor>

</p:config>

Then print-text.xpl

<?xml version="1.0" encoding="utf-8"?>


               
                <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:oxf="http://www.orbeon.com/oxf/processors"
        xmlns:saxon="http://saxon.sf.net/"
        xmlns:frf="java:org.orbeon.oxf.fr.FormRunner"
        xmlns:xf="http://www.w3.org/2002/xforms">

   
    <p:param type="input" name="xforms"/>
   
    <p:param type="input" name="parameters"/>
   
    <p:param type="output" name="data"/>

   
    <p:processor name="oxf:pipeline">
        <p:input name="config" href="/ops/pfc/xforms-epilogue.xpl"/>
        <p:input name="data" href="#xforms"/>
        <p:input name="model-data"><null xsi:nil="true"/></p:input>
        <p:input name="instance" href="#parameters"/>
        <p:output name="xformed-data" id="xformed-data"/>
    </p:processor>

    <p:processor name="oxf:request">
        <p:input name="config">
            <config><include>/request/container-namespace</include></config>
        </p:input>
        <p:output name="data" id="request"/>
    </p:processor>
        <p:processor name="oxf:xhtml-servlet-rewrite">
        <p:input name="data" href="#xformed-data"/>
        <p:output name="data" id="rewritten-data"/>
    </p:processor>

   
    <p:processor name="oxf:unsafe-xslt">
        <p:input name="config">
            <xsl:transform version="2.0">
                <xsl:import href="oxf:/oxf/xslt/utils/copy-modes.xsl"/>

                <xsl:variable name="app" select="doc('input:parameters')/*/app/string()"/>
                <xsl:variable name="form" select="doc('input:parameters')/*/form/string()"/>
                <xsl:variable name="hyperlinks" select="p:property(string-join(('oxf.fr.detail.pdf.hyperlinks', $app, $form), '.')) = true()"/>

               
                <xsl:template match="@id | @for" mode="#all">
                    <xsl:attribute name="{name()}" select="substring-after(., doc('input:request')/*/container-namespace)"/>
                </xsl:template>

               
                <xsl:template match="*:script | *:noscript" mode="#all"/>

               
                <xsl:template match="*:a" mode="#all">
                    <xsl:element name="{local-name()}">
                       
                        <xsl:apply-templates
                            select="@* except (@href[not($hyperlinks)], @shape, @target, @download, @ping, @rel, @hreflang, @type) | node()"
                            mode="#current"/>
                    </xsl:element>
                </xsl:template>

               
                <xsl:template match="*:pre[p:has-class('xforms-textarea', ..)] | *:span[p:has-class('xforms-field') and p:has-class('xforms-input', ..)]" mode="#all">
                    <xsl:element name="{local-name()}">
                        <xsl:apply-templates select="@*" mode="#current"/>
                        <xsl:apply-templates select="saxon:parse(frf:hyperlinkURLs(string(), $hyperlinks))" mode="#current"/>
                    </xsl:element>
                </xsl:template>

               
                <xsl:template match="*:div[p:has-class('xbl-fr-grid')]" mode="#all">
                    <xsl:element name="{local-name()}">
                        <xsl:apply-templates select="@* | node()" mode="in-grid"/>
                    </xsl:element>
                </xsl:template>

               
               
                <xsl:template match="*:table[p:has-class('fr-grid')]/*:tbody/*:tr[empty(*:td/*:div[p:has-class('fr-grid-content')]/*[(p:has-class(' ') or p:has-class('xbl-component')) and not(p:has-class('xforms-disabled'))])]" mode="in-grid">
                    <xsl:element name="{local-name()}">
                        <xsl:apply-templates select="@*" mode="#current"/>
                        <xsl:attribute name="class" select="'xforms-hidden'"/>
                        <xsl:apply-templates select="node()" mode="#current"/>
                    </xsl:element>
                </xsl:template>

                 
                 <xsl:template match="*:input[@type = 'hidden']" mode="#all"/>

               
                <xsl:template match="*:span[p:has-class('xforms-field') and empty(*) and normalize-space() = '']" mode="#all">
                     <xsl:element name="{local-name()}">
                         <xsl:apply-templates select="@*" mode="#current"/>
                         <xsl:text> </xsl:text>
                     </xsl:element>
                 </xsl:template>

               
                <xsl:template match="*:form" mode="#all">
                    <xsl:element name="{local-name()}">
                        <xsl:attribute name="class" select="string-join(p:classes()[. != 'xforms-initially-hidden'], ' ')"/>
                        <xsl:apply-templates select="@* except @class | node()" mode="#current"/>
                    </xsl:element>
                </xsl:template>

               
                <xsl:template match="*" mode="#all">
                    <xsl:element name="{local-name()}">
                        <xsl:apply-templates select="@* | node()" mode="#current"/>
                    </xsl:element>
                </xsl:template>

               
                <xsl:template match="*:body" mode="#all">
                    <xsl:element name="{local-name()}">
                        <xsl:apply-templates select="@*" mode="#current"/>
                        <xsl:variable name="title" select="/*/*:head/*:title/string()"/>
                        <div class="fr-header-title xforms-hidden"><div><xsl:value-of select="$title"/></div></div>
                        <div class="fr-footer-title xforms-hidden"><div><xsl:value-of select="$title"/></div></div>
                        <xsl:apply-templates select="node()" mode="#current"/>
                    </xsl:element>
                </xsl:template>
            </xsl:transform>
        </p:input>
        <p:input name="data" href="#rewritten-data"/>
        <p:input name="request" href="#request"/>
        <p:input name="parameters" href="#parameters"/>
        <p:output name="data" id="xhtml-data"/>
    </p:processor>

    <p:processor name="oxf:debug">
        <p:input name="config">
          <config><message>DEBUG before textplain xslt</message></config>
        </p:input>
        <p:input name="data" href="#xhtml-data"/>
        <p:output name="data" id="xhtml-data3"/>
    </p:processor>

   
    <p:processor name="oxf:unsafe-xslt">
        <p:input name="data" href="#xhtml-data"/>
        <p:input name="config" href="<b>text1.xsl"/>
        <p:output name="data" id="text-output"/>
    </p:processor>

    <p:processor name="oxf:text-serializer">
      <p:input name="config">
        <config>
          <content-type>text/plain</content-type>
        </config>
      </p:input>
      <p:input name="data" href="#text-output"/>
      <p:output name="data" ref="data"/>
    </p:processor>




   
   
   
       
       
           
               
               
               
           
       
       
   

</p:config>

and then in our text.xsl

<xsl:transform version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xh="http://www.w3.org/1999/xhtml"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:oxf="http://www.orbeon.com/oxf/processors"
        xmlns:p="http://www.orbeon.com/oxf/pipeline"
        xmlns:xi="http://www.w3.org/2001/XInclude"
        xmlns:xf="http://www.w3.org/2002/xforms"
        xmlns:xbl="http://www.w3.org/ns/xbl"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
        xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
        xmlns:saxon="http://saxon.sf.net/"
        xmlns:xpl="java:org.orbeon.oxf.pipeline.api.FunctionLibrary"
        xmlns:map="java:java.util.Map"
        xmlns:frf="java:org.orbeon.oxf.fr.FormRunner">
        <xsl:output method="text" />
        <xsl:strip-space elements="*" />
        <xsl:variable name="new-line" select="'&#10;'" />
        <xsl:variable name="space" select="'&#32;'" />
        <xsl:variable name="tab" select="'&#09;'" />
        <xsl:variable name="colon" select="'&#58;'" />
        <xsl:variable name="quote" select="'&#34;'" />
        <xsl:variable name="new-lines" select="concat($new-line, $new-line)" />

    <xsl:variable name="data" select="/*" as="element()"/>
       
    <xsl:variable name="parameters" select="doc('input:parameters')/*" as="element()"/>

                                       
    <xsl:variable name="is-not-a-control-classes" select="('xforms-trigger', 'xforms-disabled', 'xforms-group', 'xforms-case', 'xforms-switch', 'xforms-repeat')" as="xs:string*"/>
    <xsl:variable name="control-classes"          select="('xforms-input', 'xforms-textarea', 'xforms-select', 'xforms-select1', 'fr-attachment', 'xforms-output')" as="xs:string*"/>
    <xsl:variable name="image-attachment-classes" select="('xbl-fr-image-attachment')" as="xs:string*"/>
    <xsl:variable name="attachment-classes"       select="('fr-attachment', $image-attachment-classes)" as="xs:string*"/>

    <xsl:variable name="ids" select="//*"/>
       
       
          <xsl:template match="/">
       
        <config>
           
                       
            <template href="input:template" show-grid="false"/>

           

           
                                       
       
           
            <xsl:for-each select="//*[@id = 'fr-form-group']//*[p:classes(.) = ($control-classes, 'xbl-component') ]">
               
                <xsl:variable name="control" select="."/>
                                       
                                       
                                               
                <xsl:variable
                    name="text-field-name"
                    select="frf:buildPDFFieldNameFromHTML($control)"/>

                <xsl:if test="$text-field-name">

                    <xsl:variable name="classes" select="p:classes(.)"/>
                                         
                                         <xsl:for-each select="$control">
                                 <xsl:value-of select="."/>
                                 
                                        <br />
                                        </xsl:for-each>
                       
                                       
                   
                    <xsl:variable name="component-name" as="xs:string?">
                       
                           
                               
                                <xsl:copy-of
                                    select="
                                        for $c in $classes
                                            return substring-after($c, 'xbl-')"/>
                                                                                        <xsl:text>--bb--</xsl:text>
                                                                <xsl:value-of
                                    select="
                                        for $c in $classes
                                            return substring-after($c, 'xbl-')"/>
                       
                           
                       
                    </xsl:variable>

                    <xsl:if test="$component-name">

                        <xsl:variable
                            name="type"
                            as="xs:string?"
                            select="
                                (
                                    for $c in $classes[starts-with(., 'xforms-type-')]
                                        return substring-after($c, 'xforms-type-'),
                                    'string'
                                )[1]"/>

                       
                       

                       

                       
                       
                    </xsl:if>
                </xsl:if>
            </xsl:for-each>
        </config>
    </xsl:template>

</xsl:transform>




Reply | Threaded
Open this post in threaded view
|

Re: Want plain text in email body

emailtoakash
And we need the data in such a way that its type is "plain/text" for email processor.
Reply | Threaded
Open this post in threaded view
|

Re: Want plain text in email body

Alessandro  Vernet
Administrator
Hi Sachin, Akash,

Got it, you'd like the email to contain something like:

Employment application
---------------------

Personal information
-------------------
First name: Mary
Last name: Johnsons


Work information
--------------------
Years of experience: 5
Previous employer: Acme

As you know, the current email feature doesn't do this, and this would need to be implemented. I can't really "tell you how to do it" by some technique other than trying to implement it myself. If your organization has a PE subscription, and you'd like us at Orbeon to add this feature to the product, please get in touch with us through on your Basecamp or by email (http://www.orbeon.com/contact), and we can see what we do to help.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet