ajax and http server - cross-domain, jsonp or proxy?

Tuesday, 18 October 2011 · 10 messages · last reply 30 Nov 2011
MS
Michael Seiferlein reply to colin mcenearney, 18 Oct 2011, 18:4318 Oct 2011 16:59 #
Hi Colin, I'm glad you enjoy BaseX, and the newly added http server. I guess I'd go with 2 or 3 - where 3 maybe has the caveat that you have to have another server running. I made some good experiences using jQuery with jsonp, it's especially useful if you directly return json encoded results, our wiki [1] has some examples on serializing json. Hope this helps, feel free to further discuss (or report your experiences on) this topic in our list. Thanks Michael
Quoted text · colin mcenearney · 12 lines
Am 18.10.2011 um 16:43 schrieb colin mcenearney: > Hi, > > I just installed basex for the first time and I am very impressed and really looking forward to using it. Thanks for making such a great tool available for free! > > I'm not really a developer so this might be an obvious question: using basex's http server, what is the best strategy for ajax-style communication between browser and db? > > I am aware of a few approaches: > > 1) direct httprequest to host:8984/my_db/somequery, but going across ports seems to violate "same origin policy" > 2) using jsonp > 3) calling from browser to server-script (like the php example in basex docs), which handles request to the db
MS
Michael Seiferle18 Oct 2011 17:32 #
…[1] sorry I forgot http://docs.basex.org/wiki/JSON_Functions :-) Michael
Quoted text · Michael Seiferle · 3 lines
Am 18.10.2011 um 16:59 schrieb Michael Seiferle: > I guess I'd go with 2 or 3 - where 3 maybe has the caveat that you have to have another server running. > I made some good experiences using jQuery with jsonp, it's especially useful if you directly return json encoded results, our wiki [1] h
CG
Christian Grünin reply to colin mcenearney, 18 Oct 2011, 18:4318 Oct 2011 17:54 #
Dear Colin, thanks for your e-mail.
Quoted text · colin mcenearney · 3 lines
> I'm not really a developer so this might be an obvious question: using > basex's http server, what is the best strategy for ajax-style communication > between browser and db?
As Michael already pointed out, there is no "unique" strategy how to use BaseX with AJAX. One popular way is to use our new "json" serialization method, which allows you to directly return JSON from BaseX. A small example: 1. Start the HTTP server via "basexhttp -l" (the -l flag will communicate with the local database context; this way, no other socket connection will be used) 2. Via REST, retrieve a document or run a query and specify "jsonml" as output method: http://localhost:8984/rest/database/doc.xml?method=jsonml This way, the XML result will be directly serialized, using the JSONML syntax. If you have created your XML documents from JSON input files, you may as well use "json" as serialization format. Pleave check out our documentation as well: http://docs.basex.org/wiki/JSON_Functions Feel free to ask if this is not exactly what you are looking for. Christian
CM
colin mcenearney18 Oct 2011 18:43 #
Hi, I just installed basex for the first time and I am very impressed and really looking forward to using it. Thanks for making such a great tool available for free! I'm not really a developer so this might be an obvious question: using basex's http server, what is the best strategy for ajax-style communication between browser and db? I am aware of a few approaches: 1) direct httprequest to host:8984/my_db/somequery, but going across ports seems to violate "same origin policy" 2) using jsonp 3) calling from browser to server-script (like the php example in basex docs), which handles request to the db All responses are greatly appreciated, Colin
CM
colin mcenearneyin reply to Christian Grün, 18 Oct 2011, 17:5421 Oct 2011 08:51 #
Hi Christian and Michael, and everyone. Thanks for your replies. I'm still having a little difficulty.Attempting to return results with method=jsonml I still get this error (using jquery's ajax methods): thrown error: [Exception... "Access to restricted URI denied" code: "1012" which I think is a result of sending an http-request across different ports. I think my question might be clearer with some background: My idea for a simple app to learn the db is a blog, where each entry has its own xml file which contains, among other things, chunks of valid xhtml. I was envisioning a very simple interaction where javascript sends a get or post request and the db returns bits of xhtml. Can this be done without the use of additional server-side scripting? Maybe with direct calls to an xquery file like http://mysite.com/blog/blog.xq?categ=xmldb&level=beginner ? Colin
Quoted text · Christian Grün · 27 lines
From: Christian Grün <christian.gruen at gmail.com> To: colin mcenearney <colinmcenearney at yahoo.com> Cc: "basex-talk at mailman.uni-konstanz.de" <basex-talk at mailman.uni-konstanz.de> Sent: Tuesday, October 18, 2011 11:54 AM Subject: Re: [basex-talk] ajax and http server - cross-domain, jsonp or proxy? Dear Colin, thanks for your e-mail. > I'm not really a developer so this might be an obvious question: using > basex's http server, what is the best strategy for ajax-style communication > between browser and db? As Michael already pointed out, there is no "unique" strategy how to use BaseX with AJAX. One popular way is to use our new "json" serialization method, which allows you to directly return JSON from BaseX. A small example: 1. Start the HTTP server via "basexhttp -l" (the -l flag will communicate with the local database context; this way, no other socket connection will be used) 2. Via REST, retrieve a document or run a query and specify "jsonml" as output method: http://localhost:8984/rest/database/doc.xml?method=jsonml This way, the XML result will be directly serialized, using the JSONML syntax. If you have created your XML documents from JSON input files, you may as well use "json" as serialization format. Pleave check out our documentation as well: http://docs.basex.org/wiki/JSON_Functions Feel free to ask if this is not exactly what you are looking for. Christian
MS
Michael Seiferlein reply to Godmar Back, 22 Oct 2011, 01:2322 Oct 2011 00:07 #
Dear Godmar, Sorry if my recent reply was misleading there is no explicit support for jsonp at the moment but to build it yourself (pad the result with the help of xquery). I guess it could be added in case s/o wants to do it :-) Michael
Quoted text · Godmar Back · 86 lines
On 21.10.2011, at 23:23, Godmar Back <godmar at gmail.com> wrote: > Supporting JSON-P would be great; Michael mentioned that BaseX > supports it, but a search for JSON-P or 'callback' in the Wiki turns > up empty... > > What's the callback argument used in JSON-P called? callback? > > - Godmar > > On Fri, Oct 21, 2011 at 12:51 AM, colin mcenearney > <colinmcenearney at yahoo.com> wrote: >> Hi Christian and Michael, and everyone. >> Thanks for your replies. >> >> I'm still having a little difficulty. Attempting to return results with >> method=jsonml I still get this error (using jquery's ajax methods): >> >> thrown error: [Exception... "Access to restricted URI denied" code: "1012" >> >> which I think is a result of sending an http-request across different ports. >> >> I think my question might be clearer with some background: My idea for a >> simple app to learn the db is a blog, where each entry has its own xml file >> which contains, among other things, chunks of valid xhtml. I was envisioning >> a very simple interaction where javascript sends a get or post request and >> the db returns bits of xhtml. >> >> Can this be done without the use of additional server-side scripting? Maybe >> with direct calls to an xquery file like >> http://mysite.com/blog/blog.xq?categ=xmldb&level=beginner ? >> >> Colin >> >> ________________________________ >> From: Christian Grün <christian.gruen at gmail.com> >> To: colin mcenearney <colinmcenearney at yahoo.com> >> Cc: "basex-talk at mailman.uni-konstanz.de" >> <basex-talk at mailman.uni-konstanz.de> >> Sent: Tuesday, October 18, 2011 11:54 AM >> Subject: Re: [basex-talk] ajax and http server - cross-domain, jsonp or >> proxy? >> >> Dear Colin, >> >> thanks for your e-mail. >> >>> I'm not really a developer so this might be an obvious question: using >>> basex's http server, what is the best strategy for ajax-style >>> communication >>> between browser and db? >> >> As Michael already pointed out, there is no "unique" strategy how to >> use BaseX with AJAX. One popular way is to use our new "json" >> serialization method, which allows you to directly return JSON from >> BaseX. A small example: >> >> 1. Start the HTTP server via "basexhttp -l" (the -l flag will >> communicate with the local database context; this way, no other socket >> connection will be used) >> >> 2. Via REST, retrieve a document or run a query and specify "jsonml" >> as output method: >> http://localhost:8984/rest/database/doc.xml?method=jsonml >> >> This way, the XML result will be directly serialized, using the JSONML >> syntax. If you have created your XML documents from JSON input files, >> you may as well use "json" as serialization format. Pleave check out >> our documentation as well: >> >> http://docs.basex.org/wiki/JSON_Functions >> >> Feel free to ask if this is not exactly what you are looking for. >> Christian >> >> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
GB
Godmar Backin reply to colin mcenearney, 21 Oct 2011, 08:5122 Oct 2011 01:23 #
Supporting JSON-P would be great; Michael mentioned that BaseX supports it, but a search for JSON-P or 'callback' in the Wiki turns up empty... What's the callback argument used in JSON-P called? callback? - Godmar
Quoted text · colin mcenearney · 73 lines
On Fri, Oct 21, 2011 at 12:51 AM, colin mcenearney <colinmcenearney at yahoo.com> wrote: > Hi Christian and Michael, and everyone. > Thanks for your replies. > > I'm still having a little difficulty. Attempting to return results with > method=jsonml I still get this error (using jquery's ajax methods): > > thrown error: [Exception... "Access to restricted URI denied" code: "1012" > > which I think is a result of sending an http-request across different ports. > > I think my question might be clearer with some background: My idea for a > simple app to learn the db is a blog, where each entry has its own xml file > which contains, among other things, chunks of valid xhtml. I was envisioning > a very simple interaction where javascript sends a get or post request and > the db returns bits of xhtml. > > Can this be done without the use of additional server-side scripting? Maybe > with direct calls to an xquery file like > http://mysite.com/blog/blog.xq?categ=xmldb&level=beginner ? > > Colin > > ________________________________ > From: Christian Grün <christian.gruen at gmail.com> > To: colin mcenearney <colinmcenearney at yahoo.com> > Cc: "basex-talk at mailman.uni-konstanz.de" > <basex-talk at mailman.uni-konstanz.de> > Sent: Tuesday, October 18, 2011 11:54 AM > Subject: Re: [basex-talk] ajax and http server - cross-domain, jsonp or > proxy? > > Dear Colin, > > thanks for your e-mail. > >> I'm not really a developer so this might be an obvious question: using >> basex's http server, what is the best strategy for ajax-style >> communication >> between browser and db? > > As Michael already pointed out, there is no "unique" strategy how to > use BaseX with AJAX. One popular way is to use our new "json" > serialization method, which allows you to directly return JSON from > BaseX. A small example: > > 1. Start the HTTP server via "basexhttp -l" (the -l flag will > communicate with the local database context; this way, no other socket > connection will be used) > > 2. Via REST, retrieve a document or run a query and specify "jsonml" > as output method: > http://localhost:8984/rest/database/doc.xml?method=jsonml > > This way, the XML result will be directly serialized, using the JSONML > syntax. If you have created your XML documents from JSON input files, > you may as well use "json" as serialization format. Pleave check out > our documentation as well: > > http://docs.basex.org/wiki/JSON_Functions > > Feel free to ask if this is not exactly what you are looking for. > Christian > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
MI
Maud Ingarao30 Nov 2011 11:24 #
Hello everybody, I am very new at BaseX http server, and at jQuery, and at this mailing list too :) Concerning the error you got Colin : thrown error: [Exception... "Access to restricted URI denied" code: "1012"... I suddenly have the same problem though basex and my files have the same domain : http://hyperdonat.tge-adonis.fr/basex/basex.html (The basex server is here : http://basex.tge-adonis.fr/rest) I had other problems before this with my script, but not this one, and I don't know what I did that produced it... Maud
Quoted text · Godmar Back · 146 lines
On Fri, Oct 21, 2011 at 12:00 PM, < basex-talk-request at mailman.uni-konstanz.de> wrote: > Send BaseX-Talk mailing list submissions to > basex-talk at mailman.uni-konstanz.de > > To subscribe or unsubscribe via the World Wide Web, visit > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > or, via email, send a message with subject or body 'help' to > basex-talk-request at mailman.uni-konstanz.de > > You can reach the person managing the list at > basex-talk-owner at mailman.uni-konstanz.de > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of BaseX-Talk digest..." > > > Today's Topics: > > 1. Re: Performance of Basex 7.0 XQuery execution (Christian Gr?n) > 2. Re: Performance of Basex 7.0 XQuery execution (Jan Vl?insk? (CAD)) > 3. Clustering/replicating? (Pascal Heus) > 4. Re: ajax and http server - cross-domain, jsonp or proxy? > (colin mcenearney) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 20 Oct 2011 15:43:50 +0200 > From: Christian Gr?n <christian.gruen at gmail.com> > To: Constantine Hondros <Constantine.Hondros at tomtom.com> > Cc: "basex-talk at mailman.uni-konstanz.de" > <basex-talk at mailman.uni-konstanz.de> > Subject: Re: [basex-talk] Performance of Basex 7.0 XQuery execution > Message-ID: > <CAP94bnPYC2abLTiQJkBPt1_WquH6ix8OQeU6HnJtxCa+cp-5Vg at mail.gmail.com > > > Content-Type: text/plain; charset=ISO-8859-1 > > Hi Constantine, > > > The XPath I showed was just a simple example of using the > preceding-sibling axis. > > I guessed so already.. Thanks for persisting ;) > > > I guess what I am asking is ... while most XPath queries I run are quick > to resolve, anything using preceding::, preceding-sibling:: or following::, > following-sibling:: essentially runs too slowly to be workable - at least, > on my sample dataset with about 100K sibling children of the root element. > > > > So is this any sort of known issue? Should I be looking at any sort of > configuration options? Is there any way to profile the execution of the > Xpath? > > It's true that BaseX is mostly optimized for descendant and ancestor > operations. In particular, the preceding/preceding-sibling axes will > always be slower, as our storage does not contain backward pointers to > preceding nodes. I'm pretty sure, though, that there are ways to > either optimize relevant queries or the internal optimizer strategies, > but we'll probably have to spend some more time on analyzing the > relevant bottlenecks.. > > Feel free to ask for more, > Christian > > > ------------------------------ > > Message: 2 > Date: Thu, 20 Oct 2011 19:20:29 +0200 > From: Jan Vl?insk? (CAD) <jan.vlcinsky at cad-programs.com> > To: Christian Gr?n <christian.gruen at gmail.com> > Cc: "basex-talk at mailman.uni-konstanz.de" > <basex-talk at mailman.uni-konstanz.de> > Subject: Re: [basex-talk] Performance of Basex 7.0 XQuery execution > Message-ID: > <CAAq9E_fb5KymrtL=xosGsH=BuP4aWpgip0OWxDJUAHANqqO1Ng at mail.gmail.com > > > Content-Type: text/plain; charset="utf-8" > > Hi Constantine > Just my side note. > As far as I remember, I found this sort of performance discussion with most > the XQuery processors I have tested (Sedna, Zorba, Saxon, eXist...). Each > time related to sibling, preceding etc. and each time explaining, that > indices are not containing pointers for tracking this relationship. My > feeling is, this could lead to much bigger index file and slower > performance > when adding documents and indexing. > My conlcusion is - optimizing this sort of queries has its cost and mostly > it is better (and somehow possible) to avoid these constructions. > > With best regards > > Jan > > *Ing. Jan Vl?insk?* > CAD programy > Slune?nicov? 338/3, 734 01 Karvin? R?j, Czech Republic > tel: +420-597 602 024; mob: +420-608 979 040 > skype: janvlcinsky; GoogleTalk: jan.vlcinsky at gmail.com > http://cz.linkedin.com/in/vlcinsky > > > > On 20 October 2011 15:43, Christian Gr?n <christian.gruen at gmail.com> > wrote: > > > Hi Constantine, > > > > > The XPath I showed was just a simple example of using the > > preceding-sibling axis. > > > > I guessed so already.. Thanks for persisting ;) > > > > > I guess what I am asking is ... while most XPath queries I run are > quick > > to resolve, anything using preceding::, preceding-sibling:: or > following::, > > following-sibling:: essentially runs too slowly to be workable - at > least, > > on my sample dataset with about 100K sibling children of the root > element. > > > > > > So is this any sort of known issue? Should I be looking at any sort of > > configuration options? Is there any way to profile the execution of the > > Xpath? > > > > It's true that BaseX is mostly optimized for descendant and ancestor > > operations. In particular, the preceding/preceding-sibling axes will > > always be slower, as our storage does not contain backward pointers to > > preceding nodes. I'm pretty sure, though, that there are ways to > > either optimize relevant queries or the internal optimizer strategies, > > but we'll probably have to spend some more time on analyzing the > > relevant bottlenecks.. > > > > Feel free to ask for more, > > Christian > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > >
MI
Maud Ingarao30 Nov 2011 12:01 #
Hi again, in case it can help, I got back to a version that doesn't throw any 1012 exception. The only one difference I see is that I had removed the &callback=? in the query +++ Maud *Doesn't throw any 1012 :* // loading the lexique window.onload = function() { $.ajax({ dataType: "json", url: ' http://devictio:devictio at basex.tge-adonis.fr/rest/DonLexique', data : "method=jsonml&query=//list&callback=?",
            beforeSend: function(xhr) {
                // doesn't work, requires auth in the url...
                //xhr.setRequestHeader("Authentication", "Basic " +
Base64.encode("devictio:devictio"));
                xhr.setRequestHeader( "ContentType" , "application/json" );
            }, //may need to use "Authorization" instead
            error: function(jqXHR, textStatus, errorThrown){
                alert(textStatus + ": " + errorThrown);
            },
            success: function(result){
                alert("ok ! " + result);
                // fabriquer l'arbre dépliable avec liens cliquables
            }
}); *Throws a 1012 :*
// loading the lexique
    window.onload = function() {
        $.ajax({
            dataType: 'json',
            url: '
http://devictio:devictio at basex.tge-adonis.fr/rest/DonLexique',
            data : 'query=//list&method=jsonml',
            beforeSend: function(xhr) {
                // doesn't work, requires auth in the url...
                // xhr.setRequestHeader("Authorization", "Basic " +
Base64.encode("devictio:devictio"));
                xhr.setRequestHeader("Content-Type", "application/json");
                //xhr.overrideMimeType("application/j-son;charset=UTF-8");

            }, //May need to use "Authorization" instead
            error: function(jqXHR, textStatus, errorThrown){
                alert(textStatus + " " + errorThrown);
            },
            success: function(result){
                alert("ok ! " + result);
                // fabriquer l'arbre dépliable avec liens cliquables
            }
}); }; On Wed, Nov 30, 2011 at 11:24 AM, Maud Ingarao <maud.ingarao at ens-lyon.fr>wrote:
Quoted text · Maud Ingarao · 170 lines
> Hello everybody, > > I am very new at BaseX http server, and at jQuery, and at this mailing > list too :) > > Concerning the error you got Colin : > thrown error: [Exception... "Access to restricted URI denied" code: > "1012"... > > I suddenly have the same problem though basex and my files have the same > domain : > http://hyperdonat.tge-adonis.fr/basex/basex.html > (The basex server is here : http://basex.tge-adonis.fr/rest) > > I had other problems before this with my script, but not this one, and I > don't know what I did that produced it... > > Maud > > > > On Fri, Oct 21, 2011 at 12:00 PM, < > basex-talk-request at mailman.uni-konstanz.de> wrote: > >> Send BaseX-Talk mailing list submissions to >> basex-talk at mailman.uni-konstanz.de >> >> To subscribe or unsubscribe via the World Wide Web, visit >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> or, via email, send a message with subject or body 'help' to >> basex-talk-request at mailman.uni-konstanz.de >> >> You can reach the person managing the list at >> basex-talk-owner at mailman.uni-konstanz.de >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of BaseX-Talk digest..." >> >> >> Today's Topics: >> >> 1. Re: Performance of Basex 7.0 XQuery execution (Christian Gr?n) >> 2. Re: Performance of Basex 7.0 XQuery execution (Jan Vl?insk? (CAD)) >> 3. Clustering/replicating? (Pascal Heus) >> 4. Re: ajax and http server - cross-domain, jsonp or proxy? >> (colin mcenearney) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Thu, 20 Oct 2011 15:43:50 +0200 >> From: Christian Gr?n <christian.gruen at gmail.com> >> To: Constantine Hondros <Constantine.Hondros at tomtom.com> >> Cc: "basex-talk at mailman.uni-konstanz.de" >> <basex-talk at mailman.uni-konstanz.de> >> Subject: Re: [basex-talk] Performance of Basex 7.0 XQuery execution >> Message-ID: >> < >> CAP94bnPYC2abLTiQJkBPt1_WquH6ix8OQeU6HnJtxCa+cp-5Vg at mail.gmail.com> >> Content-Type: text/plain; charset=ISO-8859-1 >> >> Hi Constantine, >> >> > The XPath I showed was just a simple example of using the >> preceding-sibling axis. >> >> I guessed so already.. Thanks for persisting ;) >> >> > I guess what I am asking is ... while most XPath queries I run are >> quick to resolve, anything using preceding::, preceding-sibling:: or >> following::, following-sibling:: essentially runs too slowly to be workable >> - at least, on my sample dataset with about 100K sibling children of the >> root element. >> > >> > So is this any sort of known issue? Should I be looking at any sort of >> configuration options? Is there any way to profile the execution of the >> Xpath? >> >> It's true that BaseX is mostly optimized for descendant and ancestor >> operations. In particular, the preceding/preceding-sibling axes will >> always be slower, as our storage does not contain backward pointers to >> preceding nodes. I'm pretty sure, though, that there are ways to >> either optimize relevant queries or the internal optimizer strategies, >> but we'll probably have to spend some more time on analyzing the >> relevant bottlenecks.. >> >> Feel free to ask for more, >> Christian >> >> >> ------------------------------ >> >> Message: 2 >> Date: Thu, 20 Oct 2011 19:20:29 +0200 >> From: Jan Vl?insk? (CAD) <jan.vlcinsky at cad-programs.com> >> To: Christian Gr?n <christian.gruen at gmail.com> >> Cc: "basex-talk at mailman.uni-konstanz.de" >> <basex-talk at mailman.uni-konstanz.de> >> Subject: Re: [basex-talk] Performance of Basex 7.0 XQuery execution >> Message-ID: >> <CAAq9E_fb5KymrtL=xosGsH= >> BuP4aWpgip0OWxDJUAHANqqO1Ng at mail.gmail.com> >> Content-Type: text/plain; charset="utf-8" >> >> Hi Constantine >> Just my side note. >> As far as I remember, I found this sort of performance discussion with >> most >> the XQuery processors I have tested (Sedna, Zorba, Saxon, eXist...). Each >> time related to sibling, preceding etc. and each time explaining, that >> indices are not containing pointers for tracking this relationship. My >> feeling is, this could lead to much bigger index file and slower >> performance >> when adding documents and indexing. >> My conlcusion is - optimizing this sort of queries has its cost and mostly >> it is better (and somehow possible) to avoid these constructions. >> >> With best regards >> >> Jan >> >> *Ing. Jan Vl?insk?* >> CAD programy >> Slune?nicov? 338/3, 734 01 Karvin? R?j, Czech Republic >> tel: +420-597 602 024; mob: +420-608 979 040 >> skype: janvlcinsky; GoogleTalk: jan.vlcinsky at gmail.com >> http://cz.linkedin.com/in/vlcinsky >> >> >> >> On 20 October 2011 15:43, Christian Gr?n <christian.gruen at gmail.com> >> wrote: >> >> > Hi Constantine, >> > >> > > The XPath I showed was just a simple example of using the >> > preceding-sibling axis. >> > >> > I guessed so already.. Thanks for persisting ;) >> > >> > > I guess what I am asking is ... while most XPath queries I run are >> quick >> > to resolve, anything using preceding::, preceding-sibling:: or >> following::, >> > following-sibling:: essentially runs too slowly to be workable - at >> least, >> > on my sample dataset with about 100K sibling children of the root >> element. >> > > >> > > So is this any sort of known issue? Should I be looking at any sort of >> > configuration options? Is there any way to profile the execution of the >> > Xpath? >> > >> > It's true that BaseX is mostly optimized for descendant and ancestor >> > operations. In particular, the preceding/preceding-sibling axes will >> > always be slower, as our storage does not contain backward pointers to >> > preceding nodes. I'm pretty sure, though, that there are ways to >> > either optimize relevant queries or the internal optimizer strategies, >> > but we'll probably have to spend some more time on analyzing the >> > relevant bottlenecks.. >> > >> > Feel free to ask for more, >> > Christian >> > _______________________________________________ >> > BaseX-Talk mailing list >> > BaseX-Talk at mailman.uni-konstanz.de >> > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > >>
MI
Maud Ingarao30 Nov 2011 22:19 #
Hello, The support of jsonp would be very welcomed here, since several projects on tge-adonis use or will use the basex.tge-adonis.fr/rest service... For now, I went on with the proxy solution : http://hyperdonat.tge-adonis.fr/basex/basex.html Cheers, Maud
Quoted text · Maud Ingarao · 298 lines
On Sat, Oct 22, 2011 at 12:07 AM, < basex-talk-request at mailman.uni-konstanz.de> wrote: > Send BaseX-Talk mailing list submissions to > basex-talk at mailman.uni-konstanz.de > > To subscribe or unsubscribe via the World Wide Web, visit > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > or, via email, send a message with subject or body 'help' to > basex-talk-request at mailman.uni-konstanz.de > > You can reach the person managing the list at > basex-talk-owner at mailman.uni-konstanz.de > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of BaseX-Talk digest..." > > > Today's Topics: > > 1. Re: Performance of Basex 7.0 XQuery execution (Leo W?rteler) > 2. Re: Problems in using BaseX REST server - > IncompatibleClassChangeError javax.ws.rs.core.Response$Status > does not implement the requested interface (Pushkaraj Thorat) > 3. Re: ajax and http server - cross-domain, jsonp or proxy? > (Godmar Back) > 4. Re: ajax and http server - cross-domain, jsonp or proxy? > (Michael Seiferle) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 21 Oct 2011 14:12:50 +0200 > From: Leo W?rteler <lw at basex.org> > To: Constantine Hondros <Constantine.Hondros at tomtom.com> > Cc: basex-talk <basex-talk at mailman.uni-konstanz.de> > Subject: Re: [basex-talk] Performance of Basex 7.0 XQuery execution > Message-ID: <4EA161C2.3060908 at basex.org> > Content-Type: text/plain; charset=UTF-8; format=flowed > > Dear Constantine, > > Am 20.10.2011 09:44, schrieb Constantine Hondros: > > Of course, I am really interested in more useful queries such as: > > > > //tns:poi[not(tns:id = preceding-sibling::tns:poi/tns:id)] > > this query basically compiles to two nested loops, the outer one > iterating over //tns:poi and the inner one over all preceding-siblings. > So it has an O(n^2) runtime. > > > I guess what I am asking is ... while most XPath queries I run are quick > to resolve, anything using preceding::, preceding-sibling:: or following::, > following-sibling:: essentially runs too slowly to be workable - at least, > on my sample dataset with about 100K sibling children of the root element. > > Well, that's an extreme example, 100'000^2 is a huge number of nodes to > traverse. I performed some tests with > a) 10'000 sibling elements inside the root: > <root> > <item id="1"/> > <item id="2"/> > [...] > <item id="10000"/> > </root> > > and the query //item[not(preceding-sibling::*)] > > b) 10'000 nested elements: > <root> > <item id="1"> > <item id="2"> > [...] > <item id="10000"/> > [...] > </item> > </item> > </root> > > and the query //item[not(ancestor::*)] > > The timings I get are almost identical, replacing "preceding" with > "following" or "ancestor" with "descendant" doesn't change much. > > > So is this any sort of known issue? Should I be looking at any sort of > configuration options? Is there any way to profile the execution of the > Xpath? > > My guess is that the number of nodes on the *-sibling-axes is usually > much bigger than on the vertical axes, so an expensive algorithm gets > unusable earlier. > > To return to your example query, you could drastically reduce its > runtime by only traversing the database once, comparing each node only > to the nodes with unique tns:ids found before. I'll use a left fold [1][2]: > > fold-left( > function($seq, $x) { > if($seq/tns:id = $x/tns:id) then $seq > else ($seq, $x) > }, > (), > //tns:poi > ) > > If you're OK with using not-yet-standard XQuery extensions, a map [3] > instead of a sequence can potentially be even faster: > > let $map := > fold-left( > function($map, $x) { > let $key := $x/tns:id > return if(map:contains($map, $key)) then $map > else map:new(($map, map:entry($key, $x))) > }, > map:new(), > //tns:poi > ) > for $key in map:keys($map) > return $map($key) > > But this won't preserve the relative ordering of the results. > > Hope that helped, > Cheers Leo > __________ > > [1] http://www.w3.org/TR/xpath-functions-30/#func-fold-left > [2] http://en.wikipedia.org/wiki/Fold_%28higher-order_function%29 > [3] http://docs.basex.org/wiki/Map_Functions > > > ------------------------------ > > Message: 2 > Date: Sat, 22 Oct 2011 01:40:23 +0530 > From: Pushkaraj Thorat <pushkaraj.thorat.devl at gmail.com> > To: Rositsa Shadura <rositsa.shadura at uni-konstanz.de> > Cc: basex-talk at mailman.uni-konstanz.de > Subject: Re: [basex-talk] Problems in using BaseX REST server - > IncompatibleClassChangeError javax.ws.rs.core.Response$Status does > not > implement the requested interface > Message-ID: > <CAH5ngE_gf655mnLuTCAjStd2X1cmWKJQk8xYTErMyFv4QnMYeQ at mail.gmail.com > > > Content-Type: text/plain; charset="iso-8859-1" > > Thanks Rositsa! > It is bit late to reply, but indeed it is a good to know. > > Regards > Pushkaraj > > On Fri, Mar 4, 2011 at 3:01 AM, Rositsa Shadura < > rositsa.shadura at uni-konstanz.de> wrote: > > > Hi all, > > > > I've just managed accidentally to reproduce the error. I noticed that the > > class javax.ws.rs.core.Response.**Status is defined in both > > jsr311-api-1.0.jar and jersey-core-1.4.jar but only the class in the > > jersey-core JAR implements the interface > javax.ws.rs.core.Response.**StatusType. > > This is why it is important that the jersey-core JAR appears before the > > jsr311-api JAR in the classpath. When not the error occurs. > > > > Greetings, > > Rositsa > > > > > > On Thu, 20 Jan 2011 12:03:45 +0100, Michael Seiferle < > > michael.seiferle@uni-**konstanz.de <michael.seiferle at uni-konstanz.de>> > > wrote: > > > > Hi Pushkaraj, > >> > >> thanks in return for your response. > >> I will see if I can reproduce that in my VM; so far you are the first > one > >> to report this issue, I'll let you know what I can find. > >> > >> Kind regards > >> > >> Michael > >> > >> Am 19.01.2011 um 20:19 schrieb Pushkaraj Thorat: > >> > >> Thanks for your response Michael, > >>> > >>> I am using java 1.6 > >>> > >>> pushkaraj@toothless:~$ java -version > >>> java version "1.6.0_17" > >>> Java(TM) SE Runtime Environment (build 1.6.0_17-b04) > >>> Java HotSpot(TM) Server VM (build 14.3-b01, mixed mode) > >>> pushkaraj@toothless:~$ > >>> > >>> Just to update, the rest server ran successfully on my windows machine. > >>> Not sure what problem faced on the linux(ubuntu) machine. I will debug > once > >>> I get some time. > >>> > >>> Thanks, Pushkaraj > >>> > >>> > >>> On Tue, Jan 18, 2011 at 3:46 AM, Michael Seiferle > <michael.seiferle@uni- > >>> **konstanz.de <michael.seiferle at uni-konstanz.de>> wrote: > >>> Dear Pushkaraj, > >>> > >>> I am deeply sorry for you having to mess around with that erroneous > >>> startup scripts. > >>> We fixed them in both the ZIP & DMG distribution, feel free to download > >>> them again. > >>> > >>> >> java.lang.**IncompatibleClassChangeError > >>> We have been trying to reproduce this error - but to no avail. > >>> Your error message might have to do something with your Java Version; > >>> please make sure you are running the latest version. > >>> > >>> Hope this helps! In case it does not, feel free to ask for more. > >>> > >>> Kind regards > >>> > >>> Michael > >>> > >>> Am 17.01.2011 um 22:00 schrieb Pushkaraj Thorat: > >>> > >>> > I am doing setup for REST enabled basex database with procedure > >>> mentioned in http://docs.basex.org/wiki/**JAX-RX_API< > http://docs.basex.org/wiki/JAX-RX_API>URL. > >>> > > >>> > Configuring & starting server and running failed due to class not > >>> found, but later I've modified the ./basexrest script as: (Included > all the > >>> jars in lib folder) > >>> > > >>> > ######START > >>> > #!/bin/bash > >>> > # Path to this script > >>> > PWD=`dirname $0` > >>> > # Paths to distributed files or source directories > >>> > BASEX=$PWD/BaseX.jar > >>> > BASEXAPI=$PWD/../lib/basex-**api.jar > >>> > # Classpath > >>> > LIB=$PWD/../lib > >>> > LIB_CP="" > >>> > for JAR_FILE in $LIB/*.jar > >>> > do > >>> > LIB_CP="$LIB/$JAR_FILE:$LIB_**CP" > >>> > done > >>> > CP=$BASEX:$BASEXAPI:$LIB_CP > >>> > # Options for virtual machine > >>> > VM=-Xmx1g > >>> > # Run REST server > >>> > java -cp "$CP" $VM org.basex.api.jaxrx.**JaxRxServer "$@" > >>> > > >>> > ######END > >>> > > >>> > after this, server started successfully, hit the URL - > >>> http://localhost:8984/basex/**jax-rx< > http://localhost:8984/basex/jax-rx>I am getting following exception: > >>> > > >>> > java.lang.**IncompatibleClassChangeError: Class > >>> javax.ws.rs.core.Response$**Status does not implement the requested > >>> interface javax.ws.rs.core.Response$**StatusType > >>> > at > com.sun.jersey.spi.container.**ContainerResponse.getStatus(** > >>> ContainerResponse.java:548) > >>> > at com.sun.jersey.spi.container.**ContainerResponse$** > >>> CommittingOutputStream.**commitWrite(ContainerResponse.**java:156) > >>> > at com.sun.jersey.spi.container.**ContainerResponse$** > >>> CommittingOutputStream.write(**ContainerResponse.java:133) > >>> > at org.basex.io.BufferedOutput.**flush(BufferedOutput.java:50) > >>> > at org.basex.io.PrintOutput.**flush(PrintOutput.java:126) > >>> > at org.basex.data.XMLSerializer.**cls(XMLSerializer.java:206) > >>> > at org.basex.data.Serializer.**close(Serializer.java:219) > >>> > at org.basex.api.jaxrx.BXJaxRx$1.**code(BXJaxRx.java:96) > >>> > at org.basex.api.jaxrx.BXCode.**run(BXCode.java:53) > >>> > at org.basex.api.jaxrx.BXOutput.**write(BXOutput.java:53) > >>> > at com.sun.jersey.core.impl.**provider.entity.** > >>> StreamingOutputProvider.**writeTo(**StreamingOutputProvider.java:**71) > >>> > at com.sun.jersey.core.impl.**provider.entity.** > >>> StreamingOutputProvider.**writeTo(**StreamingOutputProvider.java:**57) > >>> > at com.sun.jersey.spi.container.**ContainerResponse.write(** > >>> ContainerResponse.java:299) > >>> > > >>> > >>> > >>> ______________________________**_________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-**konstanz.de <BaseX-Talk at mailman.uni-konstanz.de > > > > https://mailman.uni-konstanz.**de/mailman/listinfo/basex-talk< > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk> > > >

⚡Generated with XQuery