Login  Register

Re: Re: Re: Re: Re: How to wrap a text/plain response to xforms:submission so it becomes XML

Posted by Erik Bruchez on Dec 22, 2010; 2:12am
URL: https://discuss.orbeon.com/How-to-wrap-a-text-plain-response-to-xforms-submission-so-it-becomes-XML-tp3093245p3160016.html

Mahender,

input:results2 won't work: the XForms processor used does not support
extra inputs, and anyway, modifying an output document wouldn't do
much good.

You could also try something like this:

<root>
  <in>
    <document-to-submit>...</document-to-submit>
  </in>
  <out/>
</root>

Then use ref="/root/in/*" on the submission.

Upon successful  XML response, the output will be the XML document
returned by the service.

Upon "unsucccessful" text response, the output will look like:

<root>
  <in>
    <document-to-submit>...</document-to-submit>
  </in>
  <out>Response text</out>
</root>

You could also delete the <in> element upon xforms-submit-error.

Not sure if that helps. It is not too pretty for sure!

-Erik

On Tue, Dec 21, 2010 at 7:43 AM, Mahender Didwania
<[hidden email]> wrote:

> Hi,
>
>>In xforms-submission.xpl (the implementation of
> oxf:xforms-submission), the default instance should be the same as the
> response instance.
>
> Okay, maybe it did not work because of the '/' being used as context (judging from orbeon log).  The following works so far as context resolution is concerned, however, as in the code below, I am trying to put the result of submission failure (it is not a failure, merely a text/plain response, but submissions processor treats it as a failure) in a different input (I connect that to the pipeline output).  But I get the error: org.orbeon.saxon.trans.XPathException: Failed to load document input:results2.
>
>          <p:processor name="oxf:xforms-submission">
>            <p:input name="submission" transform="oxf:xslt" href="#TargetURL">
>              <xforms:submission xsl:version="2.0" method="post" action="{/TargetURL/text()}" xxforms:username="admin" xxforms:password="admin"  mediatype="text/xml;">
>                <xforms:message ev:event="xforms-submit-error" level="xxforms:log-error">A submission error occurred:
>                  <xforms:output value="event('error-type')"/>
>                </xforms:message>
>                <xforms:action ev:event="xforms-submit-error">
>                   <!-- this works but modifies the default-instance
>                   <xforms:insert context="fn:context()" origin="xxforms:element('Result')"/>
>                   <xforms:setvalue ref="fn:context()/Result"
>                   -->
>                   <!-- this does not work -->
>                   <xforms:insert context="fn:doc('input:results2')/Results" origin="xxforms:element('Result')"/>
>                   <xforms:setvalue ref="fn:doc('input:results2')/Results/Result"
>
>                   value="fn:choose(fn:string-length('response-reason-phrase')>0,fn:string-join((event('response-status-code') cast as xs:string,event('resource-uri'),event('response-body')),':'),'Dont know')"/>
>                </xforms:action>
>              </xforms:submission>
>            </p:input>
>            <p:input name="request" href="#xml"/>
>            <p:input name="results2" href="#results"/>
>            <p:output name="response" ref="output2"/>
>          </p:processor>
>
> Where it works, replacing <xforms:setvalue ref="fn:context()/Result" with <xforms:setvalue ref="fn:context()/*" leads to no change in the outcome.  The result is the creation of an additional <Result> element in the default-instance.
>
> #results at the time of invoking the above processor is:
>        <p:processor name="oxf:identity">
>                <p:input name="data">
>                        <Results />
>                </p:input>
>                <p:output name="data" id="results"/>
>        </p:processor>
>
> Regards,
> Mahender
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws