xformsexist-dbxsltforms

xsltforms submission method="post": Unknown XML root element


I'm using XSLTforms on exist-db server and I'm trying to load a file with method="post" with no luck at all. Here is an example of the model:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xf="http://www.w3.org/2002/xforms">
<head>
    <xf:model>
        <xf:instance xmlns="" id="default">
            <data>
                <x>
                    <a></a>
                    <b></b>
                    <c></c>
                </x>
            </data>
        </xf:instance>
        <xf:submission id="read-from-file" method="post" replace="instance" instance="default">
            <xf:resource value="'../data/test.xml'"></xf:resource>
        </xf:submission>
    </xf:model>
</head>

And here is the test.xml I'm trying to submit:

<data>
  <x>
    <a>test</a>
    <b>test</b>
    <c>test</c>
  </x>
</data>

When I trigger the submission, I get error:

xsltforms.js:8115 POST ../data/test.xml 400 (Unknown XML root element: data)

If "get" method is used instead, everything works great, as long as the file is small enough - if I try to load a bigger file with method="get" initially it's loaded, but after it's loaded once and try to reload it, I get error "414 (Request-URI Too Long)". I searched for an answer and the advise was that in this case the right way is to use "post". I'm new in xforms and obviously I do something wrong, so I need help to make this work... Thank you in advance!


Solution

  • When dealing with submission issues, it is interesting to use a browser debugger just to check what is sent and what is received.

    The GET method is clearly the one to be used to get a file content, while PUT and POST are there to push content into a file.

    By default, the default instance is serialized as GET parameters. I think that this is the reason for the URI too long alert. Since you just want to get a file content, could you please try again with "serialization" attribute set to "none"?