1

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!

nassoo
  • 59
  • 1
  • 7

1 Answers1

2

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"?

Alain Couthures
  • 1,488
  • 9
  • 5
  • Thank you so much! You saved my day :) And yes - checking the behavior in Firebug and Chrome DevTools was the first thing I've tried... I saw the long URI, but I didn't know how to get rid of it and that the instance is serialized as GET parameters. First, I've managed to workaround deleting all the elements before submission, but when the file size increased, it stopped working. For now it seems serialization="none" do the job. I hope there'll be no need to bother you again with this issue. – nassoo Mar 28 '16 at 18:10