-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi there,
I moved the following (under existdb 2.2 working) script to BaseX
https://gist.github.com/zopyx/eee05f7a421a6c0b6b80
Calling the script gives me a 404.
The hello world example script from the BaseX docs however works.
So general question: does BaseX log related errors somewhere?
At least the standard logs don't contain anything related.
Andreas
Hi Andreas,
Thanks for your feedback.
I moved the following (under existdb 2.2 working) script to BaseX https://gist.github.com/zopyx/eee05f7a421a6c0b6b80
Where did you move the file to, and which URL did you call? I just moved it into the webapp directory. When addressing the following URL...
http://localhost:8984/all-documents.html
...I got 400, because the XQuery code is specific to eXist ("Module 'http://exist-db.org/xquery/transform' not found.").
So general question: does BaseX log related errors somewhere?
At least the standard logs don't contain anything related.
Maybe the question can already solved if we find out where you moved your restxq file. – The database log files (data/.logs) should contain all relevant information. If you address an unknown URL, you should get entries like the following ones:
12:11:19.098 0:0:0:0:0:0:0:1:10572 admin REQUEST [GET] http://localhost:8984/unknown 12:11:19.499 0:0:0:0:0:0:0:1:10572 admin 404 No function found that matches the request. 12.6 ms
Hope this helps, Christian
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU4jgnAAoJEADcfz7u4AZjcxALwIvmRvRz3m9SXsAGncDh0DTt sVaBk+s4CMzwTrz9VraZyjiV87y5VpL5KWio3WhPGet3jjR3u74C09swljo07h5c 8H75VAoWpf7TjaxqaqAOI2I+VZCZtkFfwwW34zFTBlYXkly6uRMEwppofcX+zc2+ ZEfIxF7g7B/mmW37zXtJVN2/pQMbfXEJisi2hDM/87QoIKyGyBN4NqSIMCucGLto fTYElkfQILUEb8CWzGDbJBnwOLB6MrHGShEZg/YVlSsvOoalsNsSagQ4yrUP2oBb G3d9g2CT7wAjs3K6fJROd9ZS5/Vw96+jsoECayW+8SqT+phXe/tmahDbBTrjEGxJ jnhkifviGhn4eRNukPf/3ZHAa5CI96X/ANtJrsyL3zMJ5KPresMUtJZ9sftit9kx bq2oqA8E+hmDzO2snFpPflDjdOUd5ABUcYMrGx7lqOVQNTOzRatBAH3dqpmQjZLb ha5S7yApyT7+3Lk841bNiTUH3zItPJQ= =iWtX -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Both scripts (my own and the hello world script) are located inside a 'scripts' subfolder:
dav:/webdav/scripts/> ls Listing collection `/webdav/scripts/': succeeded. all-documents.xql 2717 Feb 15 17:46 all-documents.xslt 0 Feb 15 17:46 backup.xql 308 Feb 15 17:46 document-metadata.xql 3284 Feb 15 17:46 document-metadata.xslt 0 Feb 15 17:46 foo.xql 0 Feb 15 17:59 hello.xql 227 Feb 15 17:57 xml-query.xql 657 Feb 15 17:46
Calling
works.
Calling
http://host:port/all-documents.json http://host:port/all-documents.xml
does not work.
So I assume that there is something incompatible with the script. On eXist-db I would find some information related to the script within the logs about nothing can be found inside the BaseX logs.
Andreas
Christian Grün wrote:
Hi Andreas,
Thanks for your feedback.
I moved the following (under existdb 2.2 working) script to BaseX https://gist.github.com/zopyx/eee05f7a421a6c0b6b80
Where did you move the file to, and which URL did you call? I just moved it into the webapp directory. When addressing the following URL...
http://localhost:8984/all-documents.html
...I got 400, because the XQuery code is specific to eXist ("Module 'http://exist-db.org/xquery/transform' not found.").
So general question: does BaseX log related errors somewhere?
At least the standard logs don't contain anything related.
Maybe the question can already solved if we find out where you moved your restxq file. – The database log files (data/.logs) should contain all relevant information. If you address an unknown URL, you should get entries like the following ones:
12:11:19.098 0:0:0:0:0:0:0:1:10572 admin REQUEST [GET] http://localhost:8984/unknown 12:11:19.499 0:0:0:0:0:0:0:1:10572 admin 404 No function found that matches the request. 12.6 ms
Hope this helps, Christian
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU4jgnAAoJEADcfz7u4AZjcxALwIvmRvRz3m9SXsAGncDh0DTt sVaBk+s4CMzwTrz9VraZyjiV87y5VpL5KWio3WhPGet3jjR3u74C09swljo07h5c 8H75VAoWpf7TjaxqaqAOI2I+VZCZtkFfwwW34zFTBlYXkly6uRMEwppofcX+zc2+ ZEfIxF7g7B/mmW37zXtJVN2/pQMbfXEJisi2hDM/87QoIKyGyBN4NqSIMCucGLto fTYElkfQILUEb8CWzGDbJBnwOLB6MrHGShEZg/YVlSsvOoalsNsSagQ4yrUP2oBb G3d9g2CT7wAjs3K6fJROd9ZS5/Vw96+jsoECayW+8SqT+phXe/tmahDbBTrjEGxJ jnhkifviGhn4eRNukPf/3ZHAa5CI96X/ANtJrsyL3zMJ5KPresMUtJZ9sftit9kx bq2oqA8E+hmDzO2snFpPflDjdOUd5ABUcYMrGx7lqOVQNTOzRatBAH3dqpmQjZLb ha5S7yApyT7+3Lk841bNiTUH3zItPJQ= =iWtX -----END PGP SIGNATURE-----
- -- Regards Andreas Jung andreas@andreas-jung.com about.me/andreasjung
Both scripts (my own and the hello world script) are located inside a 'scripts' subfolder:
dav:/webdav/scripts/> ls
I'm a bit surprised about the 'webdav' segment in you path. Is this a sub-directory of the webapp directory (please see [1] for more information)? Or do you store all files in a database?
Calling http://host:port/hello/xxxx works.
This is probably because of the sample RESTXQ code, which you can find in webapp/restxq.xqm.
Does this help? Christian
[1] http://docs.basex.org/wiki/RESTXQ#Introduction
So I assume that there is something incompatible with the script. On eXist-db I would find some information related to the script within the logs about nothing can be found inside the BaseX logs.
Andreas
Christian Grün wrote:
Hi Andreas,
Thanks for your feedback.
I moved the following (under existdb 2.2 working) script to BaseX https://gist.github.com/zopyx/eee05f7a421a6c0b6b80
Where did you move the file to, and which URL did you call? I just moved it into the webapp directory. When addressing the following URL...
http://localhost:8984/all-documents.html
...I got 400, because the XQuery code is specific to eXist ("Module 'http://exist-db.org/xquery/transform' not found.").
So general question: does BaseX log related errors somewhere?
At least the standard logs don't contain anything related.
Maybe the question can already solved if we find out where you moved your restxq file. – The database log files (data/.logs) should contain all relevant information. If you address an unknown URL, you should get entries like the following ones:
12:11:19.098 0:0:0:0:0:0:0:1:10572 admin REQUEST [GET] http://localhost:8984/unknown 12:11:19.499 0:0:0:0:0:0:0:1:10572 admin 404 No function found that matches the request. 12.6 ms
Hope this helps, Christian
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU4jgnAAoJEADcfz7u4AZjcxALwIvmRvRz3m9SXsAGncDh0DTt sVaBk+s4CMzwTrz9VraZyjiV87y5VpL5KWio3WhPGet3jjR3u74C09swljo07h5c 8H75VAoWpf7TjaxqaqAOI2I+VZCZtkFfwwW34zFTBlYXkly6uRMEwppofcX+zc2+ ZEfIxF7g7B/mmW37zXtJVN2/pQMbfXEJisi2hDM/87QoIKyGyBN4NqSIMCucGLto fTYElkfQILUEb8CWzGDbJBnwOLB6MrHGShEZg/YVlSsvOoalsNsSagQ4yrUP2oBb G3d9g2CT7wAjs3K6fJROd9ZS5/Vw96+jsoECayW+8SqT+phXe/tmahDbBTrjEGxJ jnhkifviGhn4eRNukPf/3ZHAa5CI96X/ANtJrsyL3zMJ5KPresMUtJZ9sftit9kx bq2oqA8E+hmDzO2snFpPflDjdOUd5ABUcYMrGx7lqOVQNTOzRatBAH3dqpmQjZLb ha5S7yApyT7+3Lk841bNiTUH3zItPJQ= =iWtX -----END PGP SIGNATURE-----
Regards Andreas Jung andreas@andreas-jung.com about.me/andreasjung -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU4zKhAAoJEADcfz7u4AZjVG4Lv0+vu2zZ7OhkzdKSazLQNmcM fFEl76vQMfoMGSeXFBYqaOXsFTBjME/qMvH0v8qRzLh+vb/MGXw5nrOyBNo99bJl 6nDydx/G9Hj1iZaX6FaRTRDvrsAi/FqepeGBvbQaAKo3oOr3bXCQxxwqDw4ZmZ67 QXMMF1KtjmGipt2Y/Htj14tJ7Zz/nxomsdN37nVX6E9mWYfwyICI4R3hQHLohQMV aZHG76Fks0qVq2C4hXxEVZi3x6MwwTB+4r3jdpgpAVccS8iV+payHGyS3CCg8EYt I1mGco9uCB6rhvnt8cghHMKkQ/3XMdIWx4+XFplAqNvyq108l+ha+ztI1qrhJKVJ CKcVVk5+I132DJq9rmCRdW3m4BL2LltpNnFoAgBVGF5mERqTyLcTPD/CROXXqYvR PahgWVKkAdaRJ/tqAAmpzFTrPM+3u2hxEomM0TnaGkGL/DKZjEoKXFVJFBDX2FIW vL60rjxYGIb7HxUZMFcG8fCom0NxrJE= =2oA+ -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Christian Grün wrote:
Both scripts (my own and the hello world script) are located inside a 'scripts' subfolder:
dav:/webdav/scripts/> ls
I'm a bit surprised about the 'webdav' segment in you path. Is this a sub-directory of the webapp directory (please see [1] for more information)? Or do you store all files in a database?
Calling http://host:port/hello/xxxx works.
This is probably because of the sample RESTXQ code, which you can find in webapp/restxq.xqm.
Does this help?
Nope :-)
Q: RESTXQ scripts must be filesystem-based (location with respect to RESTXQPATH) or can I put RESTXQ script directly into the database (as I tried it as described)?
Andreas
Q: RESTXQ scripts must be filesystem-based (location with respect to RESTXQPATH)
Yep ;) The doc says: "Whenever a RESTXQ URL is requested, the RESTXQPATH module directory and its sub-directories will be parsed for functions with RESTXQ annotations".
In BaseX, you can address any database from within a single XQuery expression, so it makes most sense not to restrict RESTXQ files to a specific database.
I guess that's the answer? Probably it's solved differently in eXist-db?
or can I put RESTXQ script directly into the database (as I tried it as described)?
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU439tAAoJEADcfz7u4AZjDLsLwI23llzsiwx8Y2S03bpUbsAZ ktXbGUDHb1J7QSt/lwlOvSt/mCB4pEkf/zhR/u0LQr1EZ2UuoBeHhIVmvZPDzFwB fxJZWR3fdYEGN/1hItNwClTLYdaMmtgd7UZgY6NRwuaGYMUT4WBpBrv0ExjzFBeW w4KyNMHJPZF2v4VUWZq8UbucIzHYXMftwOiJdAJhvWWrXI3x0cbqiX/i+5jtce8d Zrc0ORECxDGFBtuicC0HH01FuAvs6WzRT0yzZRZ6V6xJMWbMDYIy48aoGMjnxwl4 dPW5HiMUE9Mbm6bzFRsloQ+mHlR4qRaakEh6PwAiSsElPJcBk7IkBn9YRivg4kbl ue6zgsa9sfk7YX6Vo8rfZggpQKvdP9fgZkpzSfPhc0NoqpmWza4nPF1l6fS5FMw+ IC61Q47mp+62yY+AdmG1N1kptmoI7xjUl2tomjHVXC70FPxcLV64WMGDN59Q81uQ 56QgeY0mfKkmlOXoPbXZGALGlzZNzvA= =YHaT -----END PGP SIGNATURE-----
Jup, in existdb you can treat RESTXQ scripts like data and throw it directly into the database instead of separating code from data like in BaseX..but thanks for clarification.
Regards Andreas Jung ----- Sorry for being brief - sent from a mobile device.
Am 17.02.2015 um 21:31 schrieb Christian Grün christian.gruen@gmail.com:
Q: RESTXQ scripts must be filesystem-based (location with respect to RESTXQPATH)
Yep ;) The doc says: "Whenever a RESTXQ URL is requested, the RESTXQPATH module directory and its sub-directories will be parsed for functions with RESTXQ annotations".
In BaseX, you can address any database from within a single XQuery expression, so it makes most sense not to restrict RESTXQ files to a specific database.
I guess that's the answer? Probably it's solved differently in eXist-db?
or can I put RESTXQ script directly into the database (as I tried it as described)?
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU439tAAoJEADcfz7u4AZjDLsLwI23llzsiwx8Y2S03bpUbsAZ ktXbGUDHb1J7QSt/lwlOvSt/mCB4pEkf/zhR/u0LQr1EZ2UuoBeHhIVmvZPDzFwB fxJZWR3fdYEGN/1hItNwClTLYdaMmtgd7UZgY6NRwuaGYMUT4WBpBrv0ExjzFBeW w4KyNMHJPZF2v4VUWZq8UbucIzHYXMftwOiJdAJhvWWrXI3x0cbqiX/i+5jtce8d Zrc0ORECxDGFBtuicC0HH01FuAvs6WzRT0yzZRZ6V6xJMWbMDYIy48aoGMjnxwl4 dPW5HiMUE9Mbm6bzFRsloQ+mHlR4qRaakEh6PwAiSsElPJcBk7IkBn9YRivg4kbl ue6zgsa9sfk7YX6Vo8rfZggpQKvdP9fgZkpzSfPhc0NoqpmWza4nPF1l6fS5FMw+ IC61Q47mp+62yY+AdmG1N1kptmoI7xjUl2tomjHVXC70FPxcLV64WMGDN59Q81uQ 56QgeY0mfKkmlOXoPbXZGALGlzZNzvA= =YHaT -----END PGP SIGNATURE-----
Hi Andreas,
Good to know. We also thought about following this approach, but it would make more sense indeed if XQuery expressions were restricted to a single database. It's actually very common that one application in BaseX accesses more than one database.
Maybe one more difference is that you can easily start more instances of BaseX – one for each application – while (I assume) you will usually only start one instance of eXist-db for all concurrently running applications.
Hope this helps, Christian
On Tue, Feb 17, 2015 at 9:42 PM, Andreas Jung lists@zopyx.com wrote:
Jup, in existdb you can treat RESTXQ scripts like data and throw it directly into the database instead of separating code from data like in BaseX..but thanks for clarification.
Regards Andreas Jung
Sorry for being brief - sent from a mobile device.
Am 17.02.2015 um 21:31 schrieb Christian Grün christian.gruen@gmail.com:
Q: RESTXQ scripts must be filesystem-based (location with respect to RESTXQPATH)
Yep ;) The doc says: "Whenever a RESTXQ URL is requested, the RESTXQPATH module directory and its sub-directories will be parsed for functions with RESTXQ annotations".
In BaseX, you can address any database from within a single XQuery expression, so it makes most sense not to restrict RESTXQ files to a specific database.
I guess that's the answer? Probably it's solved differently in eXist-db?
or can I put RESTXQ script directly into the database (as I tried it as described)?
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU439tAAoJEADcfz7u4AZjDLsLwI23llzsiwx8Y2S03bpUbsAZ ktXbGUDHb1J7QSt/lwlOvSt/mCB4pEkf/zhR/u0LQr1EZ2UuoBeHhIVmvZPDzFwB fxJZWR3fdYEGN/1hItNwClTLYdaMmtgd7UZgY6NRwuaGYMUT4WBpBrv0ExjzFBeW w4KyNMHJPZF2v4VUWZq8UbucIzHYXMftwOiJdAJhvWWrXI3x0cbqiX/i+5jtce8d Zrc0ORECxDGFBtuicC0HH01FuAvs6WzRT0yzZRZ6V6xJMWbMDYIy48aoGMjnxwl4 dPW5HiMUE9Mbm6bzFRsloQ+mHlR4qRaakEh6PwAiSsElPJcBk7IkBn9YRivg4kbl ue6zgsa9sfk7YX6Vo8rfZggpQKvdP9fgZkpzSfPhc0NoqpmWza4nPF1l6fS5FMw+ IC61Q47mp+62yY+AdmG1N1kptmoI7xjUl2tomjHVXC70FPxcLV64WMGDN59Q81uQ 56QgeY0mfKkmlOXoPbXZGALGlzZNzvA= =YHaT -----END PGP SIGNATURE-----
Andreas Jung wrote:
Christian Grün wrote:
Both scripts (my own and the hello world script) are located inside a 'scripts' subfolder:
dav:/webdav/scripts/> ls
I'm a bit surprised about the 'webdav' segment in you path. Is this a sub-directory of the webapp directory (please see [1] for more information)? Or do you store all files in a database?
Calling http://host:port/hello/xxxx works.
This is probably because of the sample RESTXQ code, which you can find in webapp/restxq.xqm.
ok, slowly making progress....
I added a stripped-down version of my script into the webapp folder
https://gist.github.com/zopyx/a0219e145d86dc154e5e
and I can access
however
gives me a 404 error.
I thought RESTXQ scripts would be compatible in some way :-)
Andreas
Hi Andreas,
I thought RESTXQ scripts would be compatible in some way :-)
Thanks for fighting through the initial difficulties. I hope that our implementations are still "in some way" compatible. With each feedback, chances increase that we get eXist and BaseX closer together. Feel free to give feedback in the RESTXQ issue tracker [1].
I can access
however
gives me a 404 error.
It works on my machine. Did you specify an Accept header in your request? I would expect it to be mandatory in eXist db as well..
curl -H"Accept:application/json" "http://localhost:8984/all-documents.json"
As an alternative, you can also remove the %rest:produces("application/json") annotation.
Best, Christian
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Christian Grün wrote:
It works on my machine. Did you specify an Accept header in your request? I would expect it to be mandatory in eXist db as well..
curl -H"Accept:application/json" "http://localhost:8984/all-documents.json"
Gotcha, existdb does not seem to care about the Accept header since it responds through such a request through the browser.
As an alternative, you can also remove the %rest:produces("application/json") annotation.
curl -H"Accept:application/json" "http://localhost:8984/all-documents.json"
This now returns the XML version of func() - however now JSON serialized response although %output:method("json") is specified!?
Andreas
curl -H"Accept:application/json" "http://localhost:8984/all-documents.json"
This now returns the XML version of func() - however now JSON serialized response although %output:method("json") is specified!?
Since Version 8.0, BaseX follows the XQuery 3.1 serialization rules, which serializes arbitrary XML nodes as JSON string [1]. There's one exception, though: BaseX XML representations of JSON documents will continue to be converted from nodes to JSON maps or arrays [2].
What was your server-side output, and what result did you expect?
[1] http://www.w3.org/TR/xslt-xquery-serialization-31/#json-output [2] http://docs.basex.org/wiki/XQuery_3.1#JSON_Serialization
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU5Io0AAoJEADcfz7u4AZj5FkLwMvw1psFIBb/JQV4q09Szasz GGa4C8TBqAc4aeYje9Bqv55rgmJL7zjDaqjKUgrgnT3mvoVwKwz6URm6pgrg2S82 fF3fw2taGnwnA2Np7eEJgaW5Lu7hByBGa+l4yGEW39s1SVgvkVnmSXrw+Cn84fpi F3XwtRdoD9nH3T9aTY3vTUs2ZqHD7oTrg8kgi57IDAxuG10WQpsZ6jsxwFgsS0Db sjgnFfg1/eLQyP9aIi12519bhoKzLnyl7GqyYoi0dgSy7ncu/2SyUQ1u8pVdEt7t gFOxC9cS/tuqYH4oQwcqXqoCNU961f/I/jdaMSeuaNzZaSn6bHLzuhkReddAJtwE RQ67XkTqXIayTFtjZP6u73Hrw/HI0NBThuug0ZwwEAiXEw9PsFDq8RWX8tFJR85m QDyAvOGXgzI/Z/9u4Zjfn2otetiCG1qSybaPD0p9P9ZA9jamSdXSeGw7GhZPLUjb MK8jRejjEQxeKr1miwCLYQGRjSxXaJQ= =iDiq -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Christian Grün wrote:
curl -H"Accept:application/json" "http://localhost:8984/all-documents.json"
This now returns the XML version of func() - however now JSON serialized response although %output:method("json") is specified!?
Since Version 8.0, BaseX follows the XQuery 3.1 serialization rules, which serializes arbitrary XML nodes as JSON string [1]. There's one exception, though: BaseX XML representations of JSON documents will continue to be converted from nodes to JSON maps or arrays [2].
What was your server-side output, and what result did you expect?
The result is XML-ish, try yourself:
curl -H"Accept:application/json" http://dev1.veit-schiele.de:8984/all-documents.json
My expectation is receiving a JSON string.
[1] http://www.w3.org/TR/xslt-xquery-serialization-31/#json-output [2] http://docs.basex.org/wiki/XQuery_3.1#JSON_Serialization
I tried to add the "declare option...." to my original code
https://gist.github.com/zopyx/a0219e145d86dc154e5e
but no BaseX love.
Andreas
The result is XML-ish, try yourself:
curl -H"Accept:application/json" http://dev1.veit-schiele.de:8984/all-documents.json
My expectation is receiving a JSON string.
This is how the XQuery spec wants it to be. If you look closely, you will see that your result starts and end with double quotes.
The problem is that it's not possible to define a lossless bidirectional mapping for XML and JSON resources. In BaseX, one way out is to use the 'jsonml' serialization format [1,2]. It can be triggered by the following annotation:
%output:json("format=jsonml")
Using JSONML, you can serialize any XML document to JSON, but the result may not necessarily look like something JS developers are used to.
[1] http://docs.basex.org/wiki/JSON_Module#JsonML [2] http://www.jsonml.org/xml/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Christian Grün wrote:
The result is XML-ish, try yourself:
curl -H"Accept:application/json" http://dev1.veit-schiele.de:8984/all-documents.json
My expectation is receiving a JSON string.
This is how the XQuery spec wants it to be. If you look closely, you will see that your result starts and end with double quotes.
The problem is that it's not possible to define a lossless bidirectional mapping for XML and JSON resources. In BaseX, one way out is to use the 'jsonml' serialization format [1,2]. It can be triggered by the following annotation:
%output:json("format=jsonml")
This was the missing link for moving a script from exist-db to BaseX. A more complete example in the docs would be helpful here.
Thanks for your patience.
Andreas
This was the missing link for moving a script from exist-db to BaseX. A more complete example in the docs would be helpful here.
To get a better understanding, could you give me a small example how eXist converts XML to JSON, or a link to their documentation? Does it also support %output:method('json')?
Thanks, Christian
Thanks for your patience.
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU5KfiAAoJEADcfz7u4AZj3jYLwJEpVwIZnKpcGEXXAeEg4DqO isWmSVI4pn9+wnlPGTtQuarHkRklIkapET9TkL8b76NXB83pFCiExgGIqeVIVZeO RAiGgj018/F5DaTSWFg0EG1uptxwBbUWkzKpIfa9HgfbgybChPTw8q2acxYDrJ0B q6jJ29xet/EvPfbjsavAuvq+Gv6HDJtum8WZ7Ex2kA7PAVUQSo5w8Y9qtqqmEVWp tGXgAjQrZCmeYkTcWZ2tJ9T/K4yBlyzleA5uX5GUJW6iCuHEZ4QgAqtUQNswgJIg h9+wQhU/R1/NlyYBelrhGKCUFLoUjdToYfJEGKPEcYd3+IDcyPfMxmAAdMoBoCg4 K+1UgdACn8xxeyYvQEKxn832UrgYhdowjEQsjXWLcWI2Mwe1F2tgAnev5SXjpbti X/zrxLzh5sUhUuj74el4VaMDWheKdTqTmxTtgJzZb/59o//TI70Bg1L5fdn2o2yS hqyp8X/tLkKbOWxLvFmFCXDv5Ls717A= =7M1F -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Christian Grün wrote:
This was the missing link for moving a script from exist-db to BaseX. A more complete example in the docs would be helpful here.
To get a better understanding, could you give me a small example how eXist converts XML to JSON, or a link to their documentation? Does it also support %output:method('json')?
This is the script that serializes to (XML), JSON and HTML in existdb
https://gist.github.com/zopyx/eee05f7a421a6c0b6b80
I can not recall where I found my primary source for RESTXQ scripts in exist but there are some of their demos
https://github.com/eXist-db/demo-apps/blob/master/examples/xforms/restxq-dem...
http://exist-db.org/exist/apps/doc/xquery.xml#serialization
My broader goal is to figure out how to write scripts for both databases in a compatible way in order to keep the necessary changes as minimal as possible.
Andreas
This is the script that serializes to (XML), JSON and HTML in existdb
Thanks. I guess it follows the conversion rules described in [1]?
My broader goal is to figure out how to write scripts for both databases in a compatible way in order to keep the necessary changes as minimal as possible.
Makes perfect sense. Do you have a particular opinion or preference when it comes to converting XML to JSON? What are your typical use cases?
I am just asking because there are so many different approaches out there, and none of them is really satisfying (the last request on our list from Florent Gallaire was just a few weeks ago). It will be impossible to cover all of them in a single implementation, but we could at least try to find a common solution for BaseX and eXist.
[1] http://exist-db.org/exist/apps/wiki/blogs/eXist/JSONSerializer [2] https://www.mail-archive.com/basex-talk@mailman.uni-konstanz.de/msg05390.htm...
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU5K3aAAoJEADcfz7u4AZjnA0LwIZMAohm1Q4A2HLIqvr6Ikis Mvlz03RGIoNpfmUqruXgTK+MDK7nVR6S15GZ0WkUBAh8gT40PxUBjX861N9oHUs+ 7UN79Rcmhw4uT9jPv47vT2Of6vx/WgE4KVpxMCevVICDuONsqQoM73CwZBmu9LqL sbsNpx3vf1sG/QOvi1c6C28fJwKNIyvyQnj3Rc3TUUnQ4ZrstFXXVbTrWvO31Cvm ND+0PjXg49u+63K5JkHtLyOM2kZQ4yDIGYuOAlhtxfTMaappILcuc/pN1UxjmRjj 7hMPTXC2EK/vEEvcYcCQiL3mZEAOpoGWibiElWfpQHHUsLPfxjQ7U0cqa5au+rT/ 74Op+rrYPkKoAXtgPZeCdlyUjTr6qpZBGzyDyPww1xELb5tz74tMbm1uZdtJD3HZ qZH7L72ZDJF10XOtXMgSv+BUwqjSdqG5tyYGzAXRqTSw6t3n2wus4MciKQonBU1S R9s279cgXjAuS08Re5CuIXdKIIvFDYc= =o8Ff -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Christian Grün wrote:
This is the script that serializes to (XML), JSON and HTML in existdb
Thanks. I guess it follows the conversion rules described in [1]?
My broader goal is to figure out how to write scripts for both databases in a compatible way in order to keep the necessary changes as minimal as possible.
Makes perfect sense. Do you have a particular opinion or preference when it comes to converting XML to JSON? What are your typical use cases?
I am the found of XML Director
and I trying to support Base-X and eXist equally. We are currently rolling out a bigger project and I am checkout how much effort it would be to moved the RESTXQ layer to BaseX. The underlaying persistence layer over WebDAV is already working on both databases.
We currently have a handful of JSON scripts doing basic aggregation for overviews or detail views from within the CMS. Sending JSON back to the CMS is more natural than having to deal with the same information as XML inside the CMS. In an upcoming phase of the project we have more specific and requirements to the XML database and so I am just playing and looking what is doable and how.
Andreas
I am the found of XML Director
Yes, I know (but probably not everyone does ;) Your project is really interesting to follow. And I appreciate your endeavours to support at least two data backends; I think we can all benefit from both adhering to the W3 standards and bringing our approaches closer together.
We currently have a handful of JSON scripts doing basic aggregation for overviews or detail views from within the CMS. Sending JSON back to the CMS is more natural than having to deal with the same information as XML inside the CMS.
I agree. That's what we do in many of our commercial applications as well. In a few cases, we are relying on the default JSON conversions; in most others, we are using XQuery code to prepare XML for a representation that better fits our particular use case.
In an upcoming phase of the project we have more specific and requirements to the XML database and so I am just playing and looking what is doable and how.
Feel free to keep us updated! Christian
Hi Andreas,
as a user of both DBs, I had similar issues which already lead to some RestXQ harmonization (e.g. https://github.com/eXist-db/exist/issues/353)
I think we could exchange some experience and try to put together a few queries that:
a) already work in both DBs b) are known to have issues with one of them
Maybe this could be extended to a set of tests, so it can be checked regularly by both implementations.
If you are interested, drop me a line and we can arrange some exchange via Chat/Tel...
Grüße vom Bodensee,
Maximilian
2015-02-18 16:20 GMT+01:00 Andreas Jung lists@zopyx.com:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Christian Grün wrote:
This was the missing link for moving a script from exist-db to BaseX. A more complete example in the docs would be helpful here.
To get a better understanding, could you give me a small example how eXist converts XML to JSON, or a link to their documentation? Does it also support %output:method('json')?
This is the script that serializes to (XML), JSON and HTML in existdb
https://gist.github.com/zopyx/eee05f7a421a6c0b6b80
I can not recall where I found my primary source for RESTXQ scripts in exist but there are some of their demos
https://github.com/eXist-db/demo-apps/blob/master/examples/xforms/restxq-dem...
http://exist-db.org/exist/apps/doc/xquery.xml#serialization
My broader goal is to figure out how to write scripts for both databases in a compatible way in order to keep the necessary changes as minimal as possible.
Andreas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJU5K3aAAoJEADcfz7u4AZjnA0LwIZMAohm1Q4A2HLIqvr6Ikis Mvlz03RGIoNpfmUqruXgTK+MDK7nVR6S15GZ0WkUBAh8gT40PxUBjX861N9oHUs+ 7UN79Rcmhw4uT9jPv47vT2Of6vx/WgE4KVpxMCevVICDuONsqQoM73CwZBmu9LqL sbsNpx3vf1sG/QOvi1c6C28fJwKNIyvyQnj3Rc3TUUnQ4ZrstFXXVbTrWvO31Cvm ND+0PjXg49u+63K5JkHtLyOM2kZQ4yDIGYuOAlhtxfTMaappILcuc/pN1UxjmRjj 7hMPTXC2EK/vEEvcYcCQiL3mZEAOpoGWibiElWfpQHHUsLPfxjQ7U0cqa5au+rT/ 74Op+rrYPkKoAXtgPZeCdlyUjTr6qpZBGzyDyPww1xELb5tz74tMbm1uZdtJD3HZ qZH7L72ZDJF10XOtXMgSv+BUwqjSdqG5tyYGzAXRqTSw6t3n2wus4MciKQonBU1S R9s279cgXjAuS08Re5CuIXdKIIvFDYc= =o8Ff -----END PGP SIGNATURE-----
basex-talk@mailman.uni-konstanz.de