xformsexist-dbxsltforms

Form not submitted to correct server scgript


I am trying to test submission of this XForm using an echo service (I have my own echo Xquery script but also tried it with the web based one you can see in the code example). My checks reveal that the xforms-submit-done event does get fired but the script in the submission resource attribute doesn't get invoked. Rather it I get a blank page within and the url remains unchanged.

Code is below.

<html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Movie Review Selector</title>
        <model xmlns="http://www.w3.org/2002/xforms">
            <instance id="movies">
                <movies xmlns="">
                    <movie id=""></movie>
                </movies>
            </instance>
            <submission id="save" resource="http://xformstest.org/cgi-bin/echo.sh" method="post" replace="all">
                <xf:message ev:event="xforms-submit-error" level="modal">Submission Error<xf:output value="event('error-type')"></xf:output>
                </xf:message>
            </submission>
        </model>
    </head>
    <body>
        <fieldset>
            <legend>
                <h3>Movie Selector</h3>
            </legend>
            <group xmlns="http://www.w3.org/2002/xforms" ref="instance('movies')">
                <repeat nodeset="movie" id="idx">
                    <input ref="@id">
                        <label>Movie Id</label>
                    </input>
                    <trigger>
                        <label>Delete</label>
                        <delete nodeset="." ev:event="DOMActivate"></delete>
                    </trigger>
                </repeat>
                <trigger>
                    <label>Add</label>
                    <action ev:event="DOMActivate">
                        <insert nodeset="movie"></insert>
                        <setvalue ref="movie[last()]/@id" value=""></setvalue>
                    </action>
                </trigger>
                <submit submission="save">
                    <label>Submit</label>
                </submit>
            </group>
        </fieldset>
    </body>
</html>

Solution

  • Duw to limitations in browsers, it's not possible to use the POST method and replace="all" in XSLTForms.

    Instead, you must use method="xml-urlencoded-post", this is a hack that only works for XSLTForms. You won't get a pure XML body in your server, but it'll be in a form field called postdata

    Take a look to this thread for a deeper explanation: http://sourceforge.net/p/xsltforms/mailman/message/24455248/

    The XQuery script should use request:get-parameter and xmldb:decode to get the document. Something like this:

    let $p := request:get-parameter( "postdata", "" );
    let $doc := xmldb:decode( $p );
    return $doc