Hi all,
We've run into a strange issue that we never experienced beforehand even if it's something we should have done thousands of time.
Consider storing a resource sent through a RestXQ POST directly to a database.
The restxq module
module namespace o = "test";
(:sendMessage: Send a new message:) declare %rest:path('test/savemsg') %rest:POST('{$body}') %rest:consumes("application/xml") function o:save-message($body as document-node()) { db:add('hereiam', $body, 'saved.xml') };
The client request:
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"> <a> <b/> </a> </http:body> </http:request> )
The resource gets stored into the DB with all the extra text nodes containing white spaces (codepoints 10 and 32) something like:
<a>
<b/>
</a>
That's pretty strange because if I PUT the resource through Basex REST interface it doesn't create the spaces and the same if I directly db:add the resource. We noticed this oddity on BaseX 8.3.1 and could verify it on a Basex 8.2 and 8.1.1 as well. It works neatly on an older 7.9 version we still have around The applies same if the resource is sent through curl or Chrome Postman. What are we doing wrong? Thanks. Marco.
Hi Marco,
I agree that this behavior is contra-intuitive. It may have been triggered by our gradual attempts to push back the default chopping of whitespaces [1].
What happens if you remove the whitespaces in your requests?
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"><a><b/></a></http:body> </http:request> )
Christian
[1] https://github.com/BaseXdb/basex/issues/913
On Mon, Dec 21, 2015 at 4:32 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi all,
We've run into a strange issue that we never experienced beforehand even if it's something we should have done thousands of time.
Consider storing a resource sent through a RestXQ POST directly to a database.
The restxq module
module namespace o = "test";
(:sendMessage: Send a new message:) declare %rest:path('test/savemsg') %rest:POST('{$body}') %rest:consumes("application/xml") function o:save-message($body as document-node()) { db:add('hereiam', $body, 'saved.xml') };
The client request:
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"> <a> <b/> </a> </http:body> </http:request> )
The resource gets stored into the DB with all the extra text nodes containing white spaces (codepoints 10 and 32) something like:
<a>
<b/>
</a>
That's pretty strange because if I PUT the resource through Basex REST interface it doesn't create the spaces and the same if I directly db:add the resource. We noticed this oddity on BaseX 8.3.1 and could verify it on a Basex 8.2 and 8.1.1 as well. It works neatly on an older 7.9 version we still have around The applies same if the resource is sent through curl or Chrome Postman. What are we doing wrong? Thanks. Marco.
Hi Christian, the same. Even if putting the xml body on one single line with no spaces at all, exactly the three codepoints 10, 32, 32 are somehow added in the stored version of the document. :-( M.
________________________________________ From: Christian Grün christian.gruen@gmail.com Sent: Tuesday, December 22, 2015 4:35 PM To: Marco Lettere Cc: BaseX Subject: Re: [basex-talk] Strange behaviour on db:add inside restxq
Hi Marco,
I agree that this behavior is contra-intuitive. It may have been triggered by our gradual attempts to push back the default chopping of whitespaces [1].
What happens if you remove the whitespaces in your requests?
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"><a><b/></a></http:body> </http:request> )
Christian
[1] https://github.com/BaseXdb/basex/issues/913
On Mon, Dec 21, 2015 at 4:32 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi all,
We've run into a strange issue that we never experienced beforehand even if it's something we should have done thousands of time.
Consider storing a resource sent through a RestXQ POST directly to a database.
The restxq module
module namespace o = "test";
(:sendMessage: Send a new message:) declare %rest:path('test/savemsg') %rest:POST('{$body}') %rest:consumes("application/xml") function o:save-message($body as document-node()) { db:add('hereiam', $body, 'saved.xml') };
The client request:
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"> <a> <b/> </a> </http:body> </http:request> )
The resource gets stored into the DB with all the extra text nodes containing white spaces (codepoints 10 and 32) something like:
<a>
<b/>
</a>
That's pretty strange because if I PUT the resource through Basex REST interface it doesn't create the spaces and the same if I directly db:add the resource. We noticed this oddity on BaseX 8.3.1 and could verify it on a Basex 8.2 and 8.1.1 as well. It works neatly on an older 7.9 version we still have around The applies same if the resource is sent through curl or Chrome Postman. What are we doing wrong? Thanks. Marco.
Ok, I’ll have a look at it. Might take some time, though!
On Tue, Dec 22, 2015 at 4:58 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi Christian, the same. Even if putting the xml body on one single line with no spaces at all, exactly the three codepoints 10, 32, 32 are somehow added in the stored version of the document. :-( M.
From: Christian Grün christian.gruen@gmail.com Sent: Tuesday, December 22, 2015 4:35 PM To: Marco Lettere Cc: BaseX Subject: Re: [basex-talk] Strange behaviour on db:add inside restxq
Hi Marco,
I agree that this behavior is contra-intuitive. It may have been triggered by our gradual attempts to push back the default chopping of whitespaces [1].
What happens if you remove the whitespaces in your requests?
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"><a><b/></a></http:body> </http:request> )
Christian
[1] https://github.com/BaseXdb/basex/issues/913
On Mon, Dec 21, 2015 at 4:32 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi all,
We've run into a strange issue that we never experienced beforehand even if it's something we should have done thousands of time.
Consider storing a resource sent through a RestXQ POST directly to a database.
The restxq module
module namespace o = "test";
(:sendMessage: Send a new message:) declare %rest:path('test/savemsg') %rest:POST('{$body}') %rest:consumes("application/xml") function o:save-message($body as document-node()) { db:add('hereiam', $body, 'saved.xml') };
The client request:
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"> <a> <b/> </a> </http:body> </http:request> )
The resource gets stored into the DB with all the extra text nodes containing white spaces (codepoints 10 and 32) something like:
<a>
<b/>
</a>
That's pretty strange because if I PUT the resource through Basex REST interface it doesn't create the spaces and the same if I directly db:add the resource. We noticed this oddity on BaseX 8.3.1 and could verify it on a Basex 8.2 and 8.1.1 as well. It works neatly on an older 7.9 version we still have around The applies same if the resource is sent through curl or Chrome Postman. What are we doing wrong? Thanks. Marco.
Take your time Christian and have nice Christmas holidays as I wish to everyone on the list! Ciao, Marco.
________________________________________ From: Christian Grün christian.gruen@gmail.com Sent: Tuesday, December 22, 2015 4:59 PM To: Marco Lettere Cc: BaseX Subject: Re: [basex-talk] Strange behaviour on db:add inside restxq
Ok, I’ll have a look at it. Might take some time, though!
On Tue, Dec 22, 2015 at 4:58 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi Christian, the same. Even if putting the xml body on one single line with no spaces at all, exactly the three codepoints 10, 32, 32 are somehow added in the stored version of the document. :-( M.
From: Christian Grün christian.gruen@gmail.com Sent: Tuesday, December 22, 2015 4:35 PM To: Marco Lettere Cc: BaseX Subject: Re: [basex-talk] Strange behaviour on db:add inside restxq
Hi Marco,
I agree that this behavior is contra-intuitive. It may have been triggered by our gradual attempts to push back the default chopping of whitespaces [1].
What happens if you remove the whitespaces in your requests?
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"><a><b/></a></http:body> </http:request> )
Christian
[1] https://github.com/BaseXdb/basex/issues/913
On Mon, Dec 21, 2015 at 4:32 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi all,
We've run into a strange issue that we never experienced beforehand even if it's something we should have done thousands of time.
Consider storing a resource sent through a RestXQ POST directly to a database.
The restxq module
module namespace o = "test";
(:sendMessage: Send a new message:) declare %rest:path('test/savemsg') %rest:POST('{$body}') %rest:consumes("application/xml") function o:save-message($body as document-node()) { db:add('hereiam', $body, 'saved.xml') };
The client request:
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"> <a> <b/> </a> </http:body> </http:request> )
The resource gets stored into the DB with all the extra text nodes containing white spaces (codepoints 10 and 32) something like:
<a>
<b/>
</a>
That's pretty strange because if I PUT the resource through Basex REST interface it doesn't create the spaces and the same if I directly db:add the resource. We noticed this oddity on BaseX 8.3.1 and could verify it on a Basex 8.2 and 8.1.1 as well. It works neatly on an older 7.9 version we still have around The applies same if the resource is sent through curl or Chrome Postman. What are we doing wrong? Thanks. Marco.
Hi Marco,
With the latest snapshot [1], XML bodies of http:send-request() arguments won’t be indented anymore. You can enforce this behaviour in all BaseX versions by adding the http:indent='no' option in the body element:
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body http:indent='no' media-type="application/xml"> <a> <b/> </a> </http:body> </http:request> )
Hope this helps, Christian
[1] http://files.basex.org/releases/latest/
On Tue, Dec 22, 2015 at 4:58 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi Christian, the same. Even if putting the xml body on one single line with no spaces at all, exactly the three codepoints 10, 32, 32 are somehow added in the stored version of the document. :-( M.
From: Christian Grün christian.gruen@gmail.com Sent: Tuesday, December 22, 2015 4:35 PM To: Marco Lettere Cc: BaseX Subject: Re: [basex-talk] Strange behaviour on db:add inside restxq
Hi Marco,
I agree that this behavior is contra-intuitive. It may have been triggered by our gradual attempts to push back the default chopping of whitespaces [1].
What happens if you remove the whitespaces in your requests?
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"><a><b/></a></http:body> </http:request> )
Christian
[1] https://github.com/BaseXdb/basex/issues/913
On Mon, Dec 21, 2015 at 4:32 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi all,
We've run into a strange issue that we never experienced beforehand even if it's something we should have done thousands of time.
Consider storing a resource sent through a RestXQ POST directly to a database.
The restxq module
module namespace o = "test";
(:sendMessage: Send a new message:) declare %rest:path('test/savemsg') %rest:POST('{$body}') %rest:consumes("application/xml") function o:save-message($body as document-node()) { db:add('hereiam', $body, 'saved.xml') };
The client request:
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"> <a> <b/> </a> </http:body> </http:request> )
The resource gets stored into the DB with all the extra text nodes containing white spaces (codepoints 10 and 32) something like:
<a>
<b/>
</a>
That's pretty strange because if I PUT the resource through Basex REST interface it doesn't create the spaces and the same if I directly db:add the resource. We noticed this oddity on BaseX 8.3.1 and could verify it on a Basex 8.2 and 8.1.1 as well. It works neatly on an older 7.9 version we still have around The applies same if the resource is sent through curl or Chrome Postman. What are we doing wrong? Thanks. Marco.
Hi Christian, thanks a lot for this! We'll give it a try soon. BR, M.
On 05/01/2016 13:44, Christian Grün wrote:
Hi Marco,
With the latest snapshot [1], XML bodies of http:send-request() arguments won’t be indented anymore. You can enforce this behaviour in all BaseX versions by adding the http:indent='no' option in the body element:
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body http:indent='no' media-type="application/xml"> <a> <b/> </a> </http:body> </http:request> )
Hope this helps, Christian
[1] http://files.basex.org/releases/latest/
On Tue, Dec 22, 2015 at 4:58 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi Christian, the same. Even if putting the xml body on one single line with no spaces at all, exactly the three codepoints 10, 32, 32 are somehow added in the stored version of the document. :-( M.
From: Christian Grün christian.gruen@gmail.com Sent: Tuesday, December 22, 2015 4:35 PM To: Marco Lettere Cc: BaseX Subject: Re: [basex-talk] Strange behaviour on db:add inside restxq
Hi Marco,
I agree that this behavior is contra-intuitive. It may have been triggered by our gradual attempts to push back the default chopping of whitespaces [1].
What happens if you remove the whitespaces in your requests?
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"><a><b/></a></http:body> </http:request> )
Christian
[1] https://github.com/BaseXdb/basex/issues/913
On Mon, Dec 21, 2015 at 4:32 PM, Marco Lettere marco.lettere@dedalus.eu wrote:
Hi all,
We've run into a strange issue that we never experienced beforehand even if it's something we should have done thousands of time.
Consider storing a resource sent through a RestXQ POST directly to a database.
The restxq module
module namespace o = "test";
(:sendMessage: Send a new message:) declare %rest:path('test/savemsg') %rest:POST('{$body}') %rest:consumes("application/xml") function o:save-message($body as document-node()) { db:add('hereiam', $body, 'saved.xml') };
The client request:
http:send-request( <http:request method="POST" href="http://localhost:8984/test/savemsg%22%3E <http:body media-type="application/xml"> <a> <b/> </a> </http:body> </http:request> )
The resource gets stored into the DB with all the extra text nodes containing white spaces (codepoints 10 and 32) something like:
<a>
<b/>
</a>
That's pretty strange because if I PUT the resource through Basex REST interface it doesn't create the spaces and the same if I directly db:add the resource. We noticed this oddity on BaseX 8.3.1 and could verify it on a Basex 8.2 and 8.1.1 as well. It works neatly on an older 7.9 version we still have around The applies same if the resource is sent through curl or Chrome Postman. What are we doing wrong? Thanks. Marco.
basex-talk@mailman.uni-konstanz.de