In fact the Json I was building was not valid. Now I understood how to fix it. Seems to work well : module namespace _ = 'getObjectTypes'; (:~ : test dev YMA :) declare %rest:path("/getObjectTypes") (: %rest:query-param("name", "{$name}", "anonymous friend") :) %output:method("json") %output:json("format=attributes") %output:json("lax=yes") function _:getObjectTypes() { let $db := db:open("simplePLM_test1")//objectType return <json type="array"> { for $n in $db return <_ type="object"> <name type="string"> {data($n/@name)} </name> <label type="string"> {data($n/@label)} </label> </_> } </json> }; Question now will be how you ouput nested structure with unknown depth. Any idea or Experience ? *Cordialement / Best Regards, * *Yoann Maingon* Minerva France *+33 6 64 32 49 66* Download Aras Innovator - Téléchargez Aras Innovator<http://www.aras.com/support/downloads/downloadInnovator.aspx> 2014-05-15 9:57 GMT+02:00 Yoann Maingon <yoann.maingon@minerva-plm.fr>:
Thx, I thought using option format=attribute would work but apparently not. So no I fixed my issue using building the json:
module namespace _ = 'getObjectTypes';
(:~ : test dev YMA :) declare %rest:path("/getObjectTypes") (: %rest:query-param("name", "{$name}", "anonymous friend") :) %output:method("json") function _:getObjectTypes() { let $db := db:open("simplePLM_test1")//objectType return <json type="object"> { for $n in $db return <objectType type="object"> <name>{data($n/@name)}</name> <label>{data($n/@label)}</label> </objectType> } </json> };
Thank you for your help !
*Cordialement / Best Regards,*
*Yoann Maingon* Minerva France
*+33 6 64 32 49 66 <%2B33%206%C2%A064%2032%2049%2066>*
Download Aras Innovator - Téléchargez Aras Innovator<http://www.aras.com/support/downloads/downloadInnovator.aspx>
2014-05-15 9:07 GMT+02:00 Arve Gengelbach <ag@basex.org>:
Bonjour Yoann,
The mapping XML –> JSON is not 1-1, i.e. not any XML can be immediately serialised to JSON. Your XML has to be in a certain format (direct, attributes, jsonml or map) as described in [JSON Module].
I suggest you to template the JSON output you expect and apply json:parse() with desired options. This is the same as specifying output options in RestXQ. By then you know which format your XML has to have. I.e. start like this...
json:parse( '{"resultat":[ {"objectType":[ {"label":"nodes", "name":"nodes"} ]}, {"objectType":[ {"label":"links", "name":"links"} ]} ]}', {"format":"direct"})
hope this helps Arve
[JSON Module] http://docs.basex.org/wiki/JSON_Module
On 15 May 2014, at 01:17, Yoann Maingon <yoann.maingon@minerva-plm.fr> wrote:
Working on this development including Basex and AngularJs, I'm stuck with the Json output. here is the error : [BXJS0002] JSON serializer: <objectType> has invalid attribute "label". Here is the xqm : module namespace _ = 'getObjectTypes';
(:~ : test dev YMA :) declare %rest:path("/getObjectTypes") (: %rest:query-param("name", "{$name}", "anonymous friend") :) %output:method("json") %output:json("lax=yes") function _:getObjectTypes() { let $db := db:open("simplePLM_test1")//objectType return <json objects="json">{$db}</json> };
If instead I export in XML I get this : <resultat>
<objectType xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" label="nodes" name="nodes"/> <objectType xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" label="links" name="links"/> </resultat>
using this xqm:
module namespace _ = 'getObjectTypes';
(:~ : test dev YMA :) declare %rest:path("/getObjectTypes") (: %rest:query-param("name", "{$name}", "anonymous friend") :) %output:method("xml") function _:getObjectTypes() { let $db := db:open("simplePLM_test1")//objectType return <resultat>{$db}</resultat> };
any idea?
Cordialement / Best Regards,
Yoann Maingon Minerva France
+33 6 64 32 49 66
Download Aras Innovator - Téléchargez Aras Innovator
2014-05-14 20:59 GMT+02:00 Yoann Maingon <yoann.maingon@minerva-plm.fr : Thx for the blog post !
I was close to make it work but now I've got an issue with Basex itself. It says can't communicate with server when I'm trying to launch the basexhttp I know it happened to me once on another computer never knew how I either fixed it or if I had my computer stolen since then.
Is there any log I should check, any cleaning advice?
Cordialement / Best Regards,
Yoann Maingon Minerva France
+33 6 64 32 49 66
Download Aras Innovator - Téléchargez Aras Innovator
2014-05-14 16:25 GMT+02:00 Andy Bunce <bunce.andy@gmail.com>:
Hi Yoann,
I do it like this: http://quodatum.wordpress.com/2014/05/14/using-angular-with-basex
/Andy
On 14 May 2014 10:53, Yoann Maingon <yoann.maingon@minerva-plm.fr> wrote: Hi,
I've got two questions about using Basex with Angular, because I still have an issue accessing the XQuery module file.
Quick feasibility question for development: If I just install basex and store my angularjs app in the webapp folder will this is be ok to interact with the database? The github repo shows a typical folder structure : https://github.com/BaseXdb/basex-contrib/tree/master/basex-web-ng What would it be if directly integrated in the basex folder? Might be a noob question, but I'm a bit struggling here. I'm looking for an easy to way to setup a dev environnement. I'm not too much about perf/dbsize for now.
Thx for your help.
Cordialement / Best Regards,
Yoann Maingon Minerva France
+33 6 64 32 49 66
Download Aras Innovator - Téléchargez Aras Innovator
2014-05-07 15:21 GMT+02:00 Alexander Holupirek <alex@holupirek.de>:
On 07.05.2014, at 09:34, Maximilian Gärber <mgaerber@arcor.de> wrote:
@basex: maybe it is time for a basex contrib page?
Nice idea!
We have just created
https://github.com/BaseXdb/basex-contrib
A github repository for
BaseX User Community Contributions
On 07.05.2014, at 01:38, Yoann Maingon <yoann.maingon@mydatalinx.com> wrote:
Does anyone as some example using either angularjs or jquery ?
We just added a first project
BaseX-Web-NG A BaseX-RestXQ-AngularJS-Bootstrap-WebApp example
motivated by your initial question (screenshot [1]):
Looking forward to your examples and contributions! Micheee and Holu
[1] https://raw.githubusercontent.com/BaseXdb/basex-contrib/master/basex-web-ng/...