BasexGui

Saturday, 17 October 2015 · 28 messages · last reply 28 Oct 2015
M
meumapple17 Oct 2015 19:21 #
Hi All, I love using the gui but I have a hard time dealing with autocomplete: is there a way to disable it in the txt editor? I think that it would also be very useful to allow view of whitespaces and tabs and have a function to prettify the code itself (do you know any for xquery?) Thank you very much for your work! Joseph
DK
Dirk Kirsten18 Oct 2015 11:52 #
Hi Joseph, I guess you are referring to the automatical insertion of closing brackets and similar stuff to "autocomplete" (we don't have a true autocomplete for more complex stuff). I am not aware that there is a way to disable this. You can prettify your code with Ctrl+Shift+F, see http://docs.basex.org/wiki/Shortcuts for more magic shortcuts. I don't think there is currently any way to visualize the whitespaces. Cheers Dirk
Quoted text · meumapple · 10 lines
On 10/17/2015 07:21 PM, meumapple wrote: > Hi All, > > I love using the gui but I have a hard time dealing with autocomplete: is there a way to disable it in the txt editor? > > I think that it would also be very useful to allow view of whitespaces and tabs and have a function to prettify the code itself (do you know any for xquery?) > > Thank you very much for your work! > > Joseph
-- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
CG
Christian Grünin reply to meumapple, 17 Oct 2015, 19:2119 Oct 2015 14:02 #
Hi Joseph,
Quoted text · meumapple · 1 line
> I love using the gui but I have a hard time dealing with autocomplete: is there a way to disable it in the txt editor?
You can disable "Automatically add characters" in the Preferences dialog. Could you please detail which autocompletions are particularly confusing for you?
Quoted text · meumapple · 1 line
> I think that it would also be very useful to allow view of whitespaces and tabs and have a function to prettify the code itself (do you know any for xquery?)
Tabs and non-breaking spaces are visualized when activating "Show invisible characters" in that same dialog.
M
meumapple19 Oct 2015 23:12 #
Hi Christian, I think there is a bug for Mac (10.x). Those options do no work and typing quotes is really difficult. First I need to press the button twice in order for one quote to appear. Then whatever button I use the other quote appears. And there are other strange behaviors which are difficult to detail (eg the cursor is moved outside adjacent quotes if the option "automatically add characters" is on). Whitespaces cannot be shown, only new line character (this happens also on a windows machine). Joseph ps I also notice that running basexgui and basex.jar are different. I added saxon9he.jar in the lib folder and it is read by basexgui but not by basex.jar. Moreover basexgui sometimes runs out of memory when basex.jar does not. Does this make sense?
Quoted text · Christian Grün · 1 line
Il giorno 19/ott/2015, alle ore 14:02, Christian Grün <christian.gruen at gmail.com> ha scritto:
Hi Joseph,
Quoted text · Christian Grün · 1 line
> I love using the gui but I have a hard time dealing with autocomplete: is there a way to disable it in the txt editor?
You can disable "Automatically add characters" in the Preferences dialog. Could you please detail which autocompletions are particularly confusing for you?
Quoted text · Christian Grün · 1 line
> I think that it would also be very useful to allow view of whitespaces and tabs and have a function to prettify the code itself (do you know any for xquery?)
Tabs and non-breaking spaces are visualized when activating "Show invisible characters" in that same dialog.
CG
Christian Grün20 Oct 2015 09:25 #
Hi Jopseph, Thanks for the details.
Quoted text · meumapple · 1 line
> I think there is a bug for Mac (10.x). Those options do no work and typing quotes is really difficult. First I need to press the button twice in order for one quote to appear.
One more question: What 'button' do you mean here?
Quoted text · meumapple · 1 line
> Whitespaces cannot be shown, only new line character (this happens also on a windows machine).
Exactly, we are only visualizing "non-breaking whitespaces" at the moment (\u00A0). This may be changed in future.
Quoted text · meumapple · 1 line
> ps I also notice that running basexgui and basex.jar are different. I added saxon9he.jar in the lib folder and it is read by basexgui but not by basex.jar. Moreover basexgui sometimes runs out of memory when basex.jar does not. Does this make sense?
If you directly run the JAR file, no other libraries will be embedded in the classpath. This is why we also provide the start scripts. You can adjust the maximum amount of assigned memory in the scripts files; look for the -Xmx flag. Hope this helps, Christian
DK
Dirk Kirstenin reply to Ron Katriel, 20 Oct 2015, 17:2020 Oct 2015 15:26 #
Hello Ron, not Christian, but I try anyway to help you :) If you say yout want a "generate consecutive numbers in a for loop" are you aware of the "at" construct for flwor expression, e.g.
    for $x at $pos in 10 to 19 return $pos
will return the numbers 1 to 10, i.e. is a consecutive counter. Cheers Dirk
Quoted text · Ron Katriel · 71 lines
On 10/20/2015 03:23 PM, Ron Katriel wrote: > Hi Christian, > > Is there a way to generate consecutive numbers in a for loop in BaseX? > I am iterating over a collection of XML files from clinicaltrials.gov > and need to tag each output record with a unique ID starting at 1. I > have seen many discussions of this (some involving incrementing a > counter in a dummy node) but have not found a clean solution that > actually works. For example, I tried to adapt the code snippet you > provided > in https://mailman.uni-konstanz.de/pipermail/basex-talk/2010-May/000259.html to > create a function that accomplishes this without referencing an > auxiliary file (see below) but cannot get past the perplexing syntax > error ([XQST0049] Duplicate declaration of static variable $root.). > > Thanks, > Ron > > > declare variable $root := <root count="0"/>; > > declare function local:getuid () as xs:integer { > let $count := $root/@count > return ( > insert node <node id='{ $count }'/> into $root, > replace value of node $count with $count + 1 > ) > }; > > On October 19, 2015 at 5:12:19 PM, meumapple (meumapple at gmail.com > <mailto:meumapple at gmail.com>) wrote: > >> Hi Christian, >> >> I think there is a bug for Mac (10.x). Those options do no work and >> typing quotes is really difficult. First I need to press the button >> twice in order for one quote to appear. Then whatever button I use >> the other quote appears. And there are other strange behaviors which >> are difficult to detail (eg the cursor is moved outside adjacent >> quotes if the option "automatically add characters" is on). >> >> Whitespaces cannot be shown, only new line character (this happens >> also on a windows machine). >> >> Joseph >> >> ps I also notice that running basexgui and basex.jar are different. I >> added saxon9he.jar in the lib folder and it is read by basexgui but >> not by basex.jar. Moreover basexgui sometimes runs out of memory when >> basex.jar does not. Does this make sense? >> >> >> >> Il giorno 19/ott/2015, alle ore 14:02, Christian Grün >> <christian.gruen at gmail.com> ha scritto: >> >> Hi Joseph, >> >> > I love using the gui but I have a hard time dealing with >> autocomplete: is there a way to disable it in the txt editor? >> >> You can disable "Automatically add characters" in the Preferences >> dialog. Could you please detail which autocompletions are particularly >> confusing for you? >> >> > I think that it would also be very useful to allow view of >> whitespaces and tabs and have a function to prettify the code itself >> (do you know any for xquery?) >> >> Tabs and non-breaking spaces are visualized when activating "Show >> invisible characters" in that same dialog.
-- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
M
meumapplein reply to Christian Grün, 20 Oct 2015, 09:2520 Oct 2015 15:32 #
I mean the double or single quotes button. I need to press it twice to see the first quotes appear. Then I can press a character button and the other quotes will show up. Thanks! J.
Quoted text · Christian Grün · 1 line
Il giorno 20/ott/2015, alle ore 09:25, Christian Grün <christian.gruen at gmail.com> ha scritto:
Hi Jopseph, Thanks for the details.
Quoted text · Christian Grün · 1 line
> I think there is a bug for Mac (10.x). Those options do no work and typing quotes is really difficult. First I need to press the button twice in order for one quote to appear.
One more question: What 'button' do you mean here?
Quoted text · Christian Grün · 1 line
> Whitespaces cannot be shown, only new line character (this happens also on a windows machine).
Exactly, we are only visualizing "non-breaking whitespaces" at the moment (\u00A0). This may be changed in future.
Quoted text · Christian Grün · 1 line
> ps I also notice that running basexgui and basex.jar are different. I added saxon9he.jar in the lib folder and it is read by basexgui but not by basex.jar. Moreover basexgui sometimes runs out of memory when basex.jar does not. Does this make sense?
If you directly run the JAR file, no other libraries will be embedded in the classpath. This is why we also provide the start scripts. You can adjust the maximum amount of assigned memory in the scripts files; look for the -Xmx flag. Hope this helps, Christian
CG
Christian Grünin reply to Ron Katriel, 20 Oct 2015, 17:2020 Oct 2015 15:33 #
Hi Ron, This may help:
  for $doc at $pos in db:open('clinicaltrials')
  return insert node attribute id { $pos } into $doc/*
Quoted text · Ron Katriel · 1 line
> ([XQST0049] Duplicate declaration of static variable $root.).
This may be due to a minor GUI error in the 8.3 release; it was already fixed in the latest snapshot [2]. Hope this helps, Christian [1] https://www.mail-archive.com/basex-talk at mailman.uni-konstanz.de/msg06960.html [2] http://files.basex.org/releases/latest
Quoted text · Ron Katriel · 56 lines
> > Thanks, > Ron > > > declare variable $root := <root count="0"/>; > > declare function local:getuid () as xs:integer { > let $count := $root/@count > return ( > insert node <node id='{ $count }'/> into $root, > replace value of node $count with $count + 1 > ) > }; > > On October 19, 2015 at 5:12:19 PM, meumapple (meumapple at gmail.com) wrote: > > Hi Christian, > > I think there is a bug for Mac (10.x). Those options do no work and typing > quotes is really difficult. First I need to press the button twice in order > for one quote to appear. Then whatever button I use the other quote appears. > And there are other strange behaviors which are difficult to detail (eg the > cursor is moved outside adjacent quotes if the option "automatically add > characters" is on). > > Whitespaces cannot be shown, only new line character (this happens also on a > windows machine). > > Joseph > > ps I also notice that running basexgui and basex.jar are different. I added > saxon9he.jar in the lib folder and it is read by basexgui but not by > basex.jar. Moreover basexgui sometimes runs out of memory when basex.jar > does not. Does this make sense? > > > > Il giorno 19/ott/2015, alle ore 14:02, Christian Grün > <christian.gruen at gmail.com> ha scritto: > > Hi Joseph, > >> I love using the gui but I have a hard time dealing with autocomplete: is >> there a way to disable it in the txt editor? > > You can disable "Automatically add characters" in the Preferences > dialog. Could you please detail which autocompletions are particularly > confusing for you? > >> I think that it would also be very useful to allow view of whitespaces and >> tabs and have a function to prettify the code itself (do you know any for >> xquery?) > > Tabs and non-breaking spaces are visualized when activating "Show > invisible characters" in that same dialog.
CG
Christian Grünin reply to Ron Katriel, 20 Oct 2015, 17:4320 Oct 2015 16:48 #
Some time ago, we provided .dmg/.app distributions. As Apple expects those files to be decorated with a signature, and as we have to pay for those signatures (whereas we don't charge for BaseX at all), we stopped providing those distributions. However, we may introduce them some time in future, let's see. You can find .app.tar.bz2 bundles of the latest official and snapshot release in our BaseX here [1]. Christian [1] http://files.basex.org/releases/
Quoted text · Ron Katriel · 85 lines
On Tue, Oct 20, 2015 at 3:43 PM, Ron Katriel <rkatriel at mdsol.com> wrote: > Thanks, Christian. I will give it a try. > > With regards to the GUI, is there a .dmg for the Mac? The BaseX website directs to brew but it appears this implies using the GUI that comes in the jar. I tried it recently but it did not work properly (was unable to type into it). > > Thanks, > Ron > >> On Oct 20, 2015, at 9:33 AM, Christian Grün <christian.gruen at gmail.com> wrote: >> >> Hi Ron, >> >> This may help: >> >> for $doc at $pos in db:open('clinicaltrials') >> return insert node attribute id { $pos } into $doc/* >> >>> ([XQST0049] Duplicate declaration of static variable $root.). >> >> This may be due to a minor GUI error in the 8.3 release; it was >> already fixed in the latest snapshot [2]. >> >> Hope this helps, >> Christian >> >> [1] https://www.mail-archive.com/basex-talk at mailman.uni-konstanz.de/msg06960.html >> [2] http://files.basex.org/releases/latest >> >> >>> >>> Thanks, >>> Ron >>> >>> >>> declare variable $root := <root count="0"/>; >>> >>> declare function local:getuid () as xs:integer { >>> let $count := $root/@count >>> return ( >>> insert node <node id='{ $count }'/> into $root, >>> replace value of node $count with $count + 1 >>> ) >>> }; >>> >>> On October 19, 2015 at 5:12:19 PM, meumapple (meumapple at gmail.com) wrote: >>> >>> Hi Christian, >>> >>> I think there is a bug for Mac (10.x). Those options do no work and typing >>> quotes is really difficult. First I need to press the button twice in order >>> for one quote to appear. Then whatever button I use the other quote appears. >>> And there are other strange behaviors which are difficult to detail (eg the >>> cursor is moved outside adjacent quotes if the option "automatically add >>> characters" is on). >>> >>> Whitespaces cannot be shown, only new line character (this happens also on a >>> windows machine). >>> >>> Joseph >>> >>> ps I also notice that running basexgui and basex.jar are different. I added >>> saxon9he.jar in the lib folder and it is read by basexgui but not by >>> basex.jar. Moreover basexgui sometimes runs out of memory when basex.jar >>> does not. Does this make sense? >>> >>> >>> >>> Il giorno 19/ott/2015, alle ore 14:02, Christian Grün >>> <christian.gruen at gmail.com> ha scritto: >>> >>> Hi Joseph, >>> >>>> I love using the gui but I have a hard time dealing with autocomplete: is >>>> there a way to disable it in the txt editor? >>> >>> You can disable "Automatically add characters" in the Preferences >>> dialog. Could you please detail which autocompletions are particularly >>> confusing for you? >>> >>>> I think that it would also be very useful to allow view of whitespaces and >>>> tabs and have a function to prettify the code itself (do you know any for >>>> xquery?) >>> >>> Tabs and non-breaking spaces are visualized when activating "Show >>> invisible characters" in that same dialog.
RK
Ron Katrielin reply to meumapple, 19 Oct 2015, 23:1220 Oct 2015 17:20 #
Hi Christian, Is there a way to generate consecutive numbers in a for loop in BaseX? I am iterating over a collection of XML files from clinicaltrials.gov and need to tag each output record with a unique ID starting at 1. I have seen many discussions of this (some involving incrementing a counter in a dummy node) but have not found a clean solution that actually works. For example, I tried to adapt the code snippet you provided in https://mailman.uni-konstanz.de/pipermail/basex-talk/2010-May/000259.html to create a function that accomplishes this without referencing an auxiliary file (see below) but cannot get past the perplexing syntax error ([XQST0049] Duplicate declaration of static variable $root.). Thanks, Ron
declare variable $root := <root count="0"/>;

declare function local:getuid () as xs:integer {
  let $count := $root/@count
  return (
    insert node <node id='{ $count }'/> into $root,
    replace value of node $count with $count + 1
  )
};
Quoted text · meumapple (meumapple at gmail.com) · 1 line
On October 19, 2015 at 5:12:19 PM, meumapple (meumapple at gmail.com) wrote:
Hi Christian, I think there is a bug for Mac (10.x). Those options do no work and typing quotes is really difficult. First I need to press the button twice in order for one quote to appear. Then whatever button I use the other quote appears. And there are other strange behaviors which are difficult to detail (eg the cursor is moved outside adjacent quotes if the option "automatically add characters" is on). Whitespaces cannot be shown, only new line character (this happens also on a windows machine). Joseph ps I also notice that running basexgui and basex.jar are different. I added saxon9he.jar in the lib folder and it is read by basexgui but not by basex.jar. Moreover basexgui sometimes runs out of memory when basex.jar does not. Does this make sense?
Quoted text · Christian Grün · 1 line
Il giorno 19/ott/2015, alle ore 14:02, Christian Grün <christian.gruen at gmail.com> ha scritto:
Hi Joseph,
Quoted text · meumapple · 1 line
> I love using the gui but I have a hard time dealing with autocomplete: is there a way to disable it in the txt editor?
You can disable "Automatically add characters" in the Preferences dialog. Could you please detail which autocompletions are particularly confusing for you?
Quoted text · meumapple · 1 line
> I think that it would also be very useful to allow view of whitespaces and tabs and have a function to prettify the code itself (do you know any for xquery?)
Tabs and non-breaking spaces are visualized when activating "Show invisible characters" in that same dialog.
RK
Ron Katrielin reply to Dirk Kirsten, 20 Oct 2015, 15:2620 Oct 2015 17:32 #
Hi Dirk, Yes, I am aware of that. The for loop in question looks like this
for $article in db:open('CTGov')/clinical_study
return file:append('conditions.xml',
  for $condition in $article/condition
  return <record> {
    <condition_id> { local:getuid() } </condition_id>,
    <nct_id> { normalize-space($article/id_info/nct_id/text()) } </nct_id>,
    <condition> { normalize-space($condition/text()) } </condition>
  } </record>
)
Adding a for loop as you suggested below will not produce the desired output (the generation has to be implicit, in lock step with the second for loop). Thanks, Ron
Quoted text · Dirk Kirsten (dk at basex.org) · 1 line
On October 20, 2015 at 9:26:52 AM, Dirk Kirsten (dk at basex.org) wrote:
Hello Ron, not Christian, but I try anyway to help you :) If you say yout want a "generate consecutive numbers in a for loop" are you aware of the "at" construct for flwor expression, e.g.
    for $x at $pos in 10 to 19 return $pos
will return the numbers 1 to 10, i.e. is a consecutive counter. Cheers Dirk
Quoted text · Ron Katriel · 1 line
On 10/20/2015 03:23 PM, Ron Katriel wrote:
Hi Christian, Is there a way to generate consecutive numbers in a for loop in BaseX? I am iterating over a collection of XML files from clinicaltrials.gov and need to tag each output record with a unique ID starting at 1. I have seen many discussions of this (some involving incrementing a counter in a dummy node) but have not found a clean solution that actually works. For example, I tried to adapt the code snippet you provided in https://mailman.uni-konstanz.de/pipermail/basex-talk/2010-May/000259.html to create a function that accomplishes this without referencing an auxiliary file (see below) but cannot get past the perplexing syntax error ([XQST0049] Duplicate declaration of static variable $root.). Thanks, Ron
declare variable $root := <root count="0"/>;

declare function local:getuid () as xs:integer {
  let $count := $root/@count
  return (
    insert node <node id='{ $count }'/> into $root,
    replace value of node $count with $count + 1
  )
};
Quoted text · meumapple (meumapple at gmail.com) · 1 line
On October 19, 2015 at 5:12:19 PM, meumapple (meumapple at gmail.com) wrote:
Hi Christian, I think there is a bug for Mac (10.x). Those options do no work and typing quotes is really difficult. First I need to press the button twice in order for one quote to appear. Then whatever button I use the other quote appears. And there are other strange behaviors which are difficult to detail (eg the cursor is moved outside adjacent quotes if the option "automatically add characters" is on). Whitespaces cannot be shown, only new line character (this happens also on a windows machine). Joseph ps I also notice that running basexgui and basex.jar are different. I added saxon9he.jar in the lib folder and it is read by basexgui but not by basex.jar. Moreover basexgui sometimes runs out of memory when basex.jar does not. Does this make sense?
Quoted text · Christian Grün · 1 line
Il giorno 19/ott/2015, alle ore 14:02, Christian Grün <christian.gruen at gmail.com> ha scritto:
Hi Joseph,
Quoted text · Dirk Kirsten · 1 line
> I love using the gui but I have a hard time dealing with autocomplete: is there a way to disable it in the txt editor?
You can disable "Automatically add characters" in the Preferences dialog. Could you please detail which autocompletions are particularly confusing for you?
Quoted text · Dirk Kirsten · 1 line
> I think that it would also be very useful to allow view of whitespaces and tabs and have a function to prettify the code itself (do you know any for xquery?)
Tabs and non-breaking spaces are visualized when activating "Show invisible characters" in that same dialog.
-- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
RK
Ron Katrielin reply to Christian Grün, 20 Oct 2015, 15:3320 Oct 2015 17:43 #
Thanks, Christian. I will give it a try. With regards to the GUI, is there a .dmg for the Mac? The BaseX website directs to brew but it appears this implies using the GUI that comes in the jar. I tried it recently but it did not work properly (was unable to type into it). Thanks, Ron
Quoted text · Christian Grün · 77 lines
> On Oct 20, 2015, at 9:33 AM, Christian Grün <christian.gruen at gmail.com> wrote: > > Hi Ron, > > This may help: > > for $doc at $pos in db:open('clinicaltrials') > return insert node attribute id { $pos } into $doc/* > >> ([XQST0049] Duplicate declaration of static variable $root.). > > This may be due to a minor GUI error in the 8.3 release; it was > already fixed in the latest snapshot [2]. > > Hope this helps, > Christian > > [1] https://www.mail-archive.com/basex-talk at mailman.uni-konstanz.de/msg06960.html > [2] http://files.basex.org/releases/latest > > >> >> Thanks, >> Ron >> >> >> declare variable $root := <root count="0"/>; >> >> declare function local:getuid () as xs:integer { >> let $count := $root/@count >> return ( >> insert node <node id='{ $count }'/> into $root, >> replace value of node $count with $count + 1 >> ) >> }; >> >> On October 19, 2015 at 5:12:19 PM, meumapple (meumapple at gmail.com) wrote: >> >> Hi Christian, >> >> I think there is a bug for Mac (10.x). Those options do no work and typing >> quotes is really difficult. First I need to press the button twice in order >> for one quote to appear. Then whatever button I use the other quote appears. >> And there are other strange behaviors which are difficult to detail (eg the >> cursor is moved outside adjacent quotes if the option "automatically add >> characters" is on). >> >> Whitespaces cannot be shown, only new line character (this happens also on a >> windows machine). >> >> Joseph >> >> ps I also notice that running basexgui and basex.jar are different. I added >> saxon9he.jar in the lib folder and it is read by basexgui but not by >> basex.jar. Moreover basexgui sometimes runs out of memory when basex.jar >> does not. Does this make sense? >> >> >> >> Il giorno 19/ott/2015, alle ore 14:02, Christian Grün >> <christian.gruen at gmail.com> ha scritto: >> >> Hi Joseph, >> >>> I love using the gui but I have a hard time dealing with autocomplete: is >>> there a way to disable it in the txt editor? >> >> You can disable "Automatically add characters" in the Preferences >> dialog. Could you please detail which autocompletions are particularly >> confusing for you? >> >>> I think that it would also be very useful to allow view of whitespaces and >>> tabs and have a function to prettify the code itself (do you know any for >>> xquery?) >> >> Tabs and non-breaking spaces are visualized when activating "Show >> invisible characters" in that same dialog.
RS
Rob Stapper22 Oct 2015 09:07 #
Hi Ron, Maybe the attached codes-nippet is useful to you. It is an example of stateful programming, which isn't compliant with the functional programming concept but, in some cases, can be very useful. Hopes it helps, Rob Stapper PS. put the module-file in a subdirectory: "counter", in your basex-repo-directory. -----Oorspronkelijk bericht-----
Quoted text · basex-talk-bounces at mailman.uni-konstanz.de · 90 lines
Van: basex-talk-bounces at mailman.uni-konstanz.de [mailto:basex-talk-bounces at mailman.uni-konstanz.de] Namens Ron Katriel Verzonden: dinsdag 20 oktober 2015 15:43 Aan: Christian Grün CC: BaseX Onderwerp: Re: [basex-talk] Generating consecutive integers in a for loop Thanks, Christian. I will give it a try. With regards to the GUI, is there a .dmg for the Mac? The BaseX website directs to brew but it appears this implies using the GUI that comes in the jar. I tried it recently but it did not work properly (was unable to type into it). Thanks, Ron > On Oct 20, 2015, at 9:33 AM, Christian Grün <christian.gruen at gmail.com> wrote: > > Hi Ron, > > This may help: > > for $doc at $pos in db:open('clinicaltrials') return insert node > attribute id { $pos } into $doc/* > >> ([XQST0049] Duplicate declaration of static variable $root.). > > This may be due to a minor GUI error in the 8.3 release; it was > already fixed in the latest snapshot [2]. > > Hope this helps, > Christian > > [1] > https://www.mail-archive.com/basex-talk at mailman.uni-konstanz.de/msg069 > 60.html [2] http://files.basex.org/releases/latest > > >> >> Thanks, >> Ron >> >> >> declare variable $root := <root count="0"/>; >> >> declare function local:getuid () as xs:integer { let $count := >> $root/@count return ( >> insert node <node id='{ $count }'/> into $root, >> replace value of node $count with $count + 1 >> ) >> }; >> >> On October 19, 2015 at 5:12:19 PM, meumapple (meumapple at gmail.com) wrote: >> >> Hi Christian, >> >> I think there is a bug for Mac (10.x). Those options do no work and >> typing quotes is really difficult. First I need to press the button >> twice in order for one quote to appear. Then whatever button I use the other quote appears. >> And there are other strange behaviors which are difficult to detail >> (eg the cursor is moved outside adjacent quotes if the option >> "automatically add characters" is on). >> >> Whitespaces cannot be shown, only new line character (this happens >> also on a windows machine). >> >> Joseph >> >> ps I also notice that running basexgui and basex.jar are different. I >> added saxon9he.jar in the lib folder and it is read by basexgui but >> not by basex.jar. Moreover basexgui sometimes runs out of memory when >> basex.jar does not. Does this make sense? >> >> >> >> Il giorno 19/ott/2015, alle ore 14:02, Christian Grün >> <christian.gruen at gmail.com> ha scritto: >> >> Hi Joseph, >> >>> I love using the gui but I have a hard time dealing with >>> autocomplete: is there a way to disable it in the txt editor? >> >> You can disable "Automatically add characters" in the Preferences >> dialog. Could you please detail which autocompletions are >> particularly confusing for you? >> >>> I think that it would also be very useful to allow view of >>> whitespaces and tabs and have a function to prettify the code itself >>> (do you know any for >>> xquery?) >> >> Tabs and non-breaking spaces are visualized when activating "Show >> invisible characters" in that same dialog. --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. https://www.avast.com/antivirus
CG
Christian Grün22 Oct 2015 09:38 #
Hi Rob, A short variant of your approach could look like this:
  import module namespace counter =
    'java.util.concurrent.atomic.AtomicInteger';
  for $i in 1 to 10
  return counter:incrementAndGet()
As you already indicated, it violates the functional programming design, so I would surely recommend everyone to use the GFLWOR "at" or "count" clause (or possibly fold-left, etc.) And hi Ron, Do you need to start with an existing counter when running your query, or is it sufficient to start with 1? Christian
Quoted text · Rob Stapper · 10 lines
On Thu, Oct 22, 2015 at 9:07 AM, Rob Stapper <r.stapper at lijbrandt.nl> wrote: > Hi Ron, > > Maybe the attached codes-nippet is useful to you. > It is an example of stateful programming, which isn't compliant with the functional programming concept but, in some cases, can be very useful. > > Hopes it helps, > Rob Stapper > > PS. put the module-file in a subdirectory: "counter", in your basex-repo-directory.
MG
Marc van Grootel22 Oct 2015 11:47 #
Hi, Wouldn't clj-ds [1] be of any help in this? It has support for transients.I believe that Exist uses this somewhere in their code not sure where. I think it makes use of these Atomic* objects under the hood but providing a "functional" facade. btw I'm not speaking from experience with this library but I do have it on my longlist. [1]: https://github.com/krukow/clj-ds
Quoted text · Christian Grün · 33 lines
On Thu, Oct 22, 2015 at 9:38 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Rob, > > A short variant of your approach could look like this: > > import module namespace counter = > 'java.util.concurrent.atomic.AtomicInteger'; > for $i in 1 to 10 > return counter:incrementAndGet() > > As you already indicated, it violates the functional programming > design, so I would surely recommend everyone to use the GFLWOR "at" or > "count" clause (or possibly fold-left, etc.) > > And hi Ron, > > Do you need to start with an existing counter when running your query, > or is it sufficient to start with 1? > > Christian > > > On Thu, Oct 22, 2015 at 9:07 AM, Rob Stapper <r.stapper at lijbrandt.nl> wrote: >> Hi Ron, >> >> Maybe the attached codes-nippet is useful to you. >> It is an example of stateful programming, which isn't compliant with the functional programming concept but, in some cases, can be very useful. >> >> Hopes it helps, >> Rob Stapper >> >> PS. put the module-file in a subdirectory: "counter", in your basex-repo-directory.
-- --Marc
RK
Ron Katriel23 Oct 2015 02:00 #
Thanks all! I went with the solution suggested by Christian. It is simple, efficient, and solves my problem (starting at 1 is fine). The GFLWOR approach is nice, except that I have two nested for loops so it produces two counts instead of one (and there is no straightforward way to combine them into a single monotonically increasing number). Best, Ron
Quoted text · Marc van Grootel (marc.van.grootel at gmail.com) · 1 line
On October 22, 2015 at 5:47:53 AM, Marc van Grootel (marc.van.grootel at gmail.com) wrote:
Hi, Wouldn't clj-ds [1] be of any help in this? It has support for transients.I believe that Exist uses this somewhere in their code not sure where. I think it makes use of these Atomic* objects under the hood but providing a "functional" facade. btw I'm not speaking from experience with this library but I do have it on my longlist. [1]: https://github.com/krukow/clj-ds
Quoted text · Christian Grün · 33 lines
On Thu, Oct 22, 2015 at 9:38 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Rob, > > A short variant of your approach could look like this: > > import module namespace counter = > 'java.util.concurrent.atomic.AtomicInteger'; > for $i in 1 to 10 > return counter:incrementAndGet() > > As you already indicated, it violates the functional programming > design, so I would surely recommend everyone to use the GFLWOR "at" or > "count" clause (or possibly fold-left, etc.) > > And hi Ron, > > Do you need to start with an existing counter when running your query, > or is it sufficient to start with 1? > > Christian > > > On Thu, Oct 22, 2015 at 9:07 AM, Rob Stapper <r.stapper at lijbrandt.nl> wrote: >> Hi Ron, >> >> Maybe the attached codes-nippet is useful to you. >> It is an example of stateful programming, which isn't compliant with the functional programming concept but, in some cases, can be very useful. >> >> Hopes it helps, >> Rob Stapper >> >> PS. put the module-file in a subdirectory: "counter", in your basex-repo-directory.
-- --Marc
CG
Christian Grün23 Oct 2015 15:36 #
Hi Ron, Out of interest: did you have a look at the "count" clause [1]? Christian [1] http://docs.basex.org/wiki/XQuery_3.0#Enhanced_FLWOR_Expressions
Quoted text · Ron Katriel · 66 lines
On Fri, Oct 23, 2015 at 12:02 AM, Ron Katriel <rkatriel at mdsol.com> wrote: > Thanks all! > > I went with the solution suggested by Christian. It is simple, efficient, > and solves my problem (starting at 1 is fine). The GFLWOR approach is nice, > except that I have two nested for loops so it produces two counts instead of > one (and there is no straightforward way to combine them into a single > monotonically increasing number). > > Best, > Ron > > On October 22, 2015 at 5:47:53 AM, Marc van Grootel > (marc.van.grootel at gmail.com) wrote: > > Hi, > > Wouldn't clj-ds [1] be of any help in this? It has support for > transients.I believe that Exist uses this somewhere in their code not > sure where. I think it makes use of these Atomic* objects under the > hood but providing a "functional" facade. btw I'm not speaking from > experience with this library but I do have it on my longlist. > > [1]: https://github.com/krukow/clj-ds > > On Thu, Oct 22, 2015 at 9:38 AM, Christian Grün > <christian.gruen at gmail.com> wrote: >> Hi Rob, >> >> A short variant of your approach could look like this: >> >> import module namespace counter = >> 'java.util.concurrent.atomic.AtomicInteger'; >> for $i in 1 to 10 >> return counter:incrementAndGet() >> >> As you already indicated, it violates the functional programming >> design, so I would surely recommend everyone to use the GFLWOR "at" or >> "count" clause (or possibly fold-left, etc.) >> >> And hi Ron, >> >> Do you need to start with an existing counter when running your query, >> or is it sufficient to start with 1? >> >> Christian >> >> >> On Thu, Oct 22, 2015 at 9:07 AM, Rob Stapper <r.stapper at lijbrandt.nl> >> wrote: >>> Hi Ron, >>> >>> Maybe the attached codes-nippet is useful to you. >>> It is an example of stateful programming, which isn't compliant with the >>> functional programming concept but, in some cases, can be very useful. >>> >>> Hopes it helps, >>> Rob Stapper >>> >>> PS. put the module-file in a subdirectory: "counter", in your >>> basex-repo-directory. > > > > -- > --Marc
CG
Christian Grünin reply to Ron Katriel, 23 Oct 2015, 17:5123 Oct 2015 15:52 #
Perfect. Feel free to check out XQuery 3.1 as well: http://docs.basex.org/wiki/XQuery_3.1
Quoted text · Ron Katriel · 100 lines
On Fri, Oct 23, 2015 at 3:53 PM, Ron Katriel <rkatriel at mdsol.com> wrote: > Hi Cristian, > > I tried the nested for loops below and it performed as expected > (monotonically increasing count). > > There are a a lot of great enhancements in XQuery 3.0. Thanks for pointing > that out! > > Thanks, > Ron > > > for $n in (1 to 10)[. mod 2 = 1] > for $m in (1 to 10)[. mod 2 = 0] > count $c > return <number count="{ $c }" odd="{ $n }" even="{ $m }"/> > > > On October 23, 2015 at 9:36:35 AM, Christian Grün > (christian.gruen at gmail.com) wrote: > > Hi Ron, > > Out of interest: did you have a look at the "count" clause [1]? > > Christian > > [1] http://docs.basex.org/wiki/XQuery_3.0#Enhanced_FLWOR_Expressions > > > > On Fri, Oct 23, 2015 at 12:02 AM, Ron Katriel <rkatriel at mdsol.com> wrote: >> Thanks all! >> >> I went with the solution suggested by Christian. It is simple, efficient, >> and solves my problem (starting at 1 is fine). The GFLWOR approach is >> nice, >> except that I have two nested for loops so it produces two counts instead >> of >> one (and there is no straightforward way to combine them into a single >> monotonically increasing number). >> >> Best, >> Ron >> >> On October 22, 2015 at 5:47:53 AM, Marc van Grootel >> (marc.van.grootel at gmail.com) wrote: >> >> Hi, >> >> Wouldn't clj-ds [1] be of any help in this? It has support for >> transients.I believe that Exist uses this somewhere in their code not >> sure where. I think it makes use of these Atomic* objects under the >> hood but providing a "functional" facade. btw I'm not speaking from >> experience with this library but I do have it on my longlist. >> >> [1]: https://github.com/krukow/clj-ds >> >> On Thu, Oct 22, 2015 at 9:38 AM, Christian Grün >> <christian.gruen at gmail.com> wrote: >>> Hi Rob, >>> >>> A short variant of your approach could look like this: >>> >>> import module namespace counter = >>> 'java.util.concurrent.atomic.AtomicInteger'; >>> for $i in 1 to 10 >>> return counter:incrementAndGet() >>> >>> As you already indicated, it violates the functional programming >>> design, so I would surely recommend everyone to use the GFLWOR "at" or >>> "count" clause (or possibly fold-left, etc.) >>> >>> And hi Ron, >>> >>> Do you need to start with an existing counter when running your query, >>> or is it sufficient to start with 1? >>> >>> Christian >>> >>> >>> On Thu, Oct 22, 2015 at 9:07 AM, Rob Stapper <r.stapper at lijbrandt.nl> >>> wrote: >>>> Hi Ron, >>>> >>>> Maybe the attached codes-nippet is useful to you. >>>> It is an example of stateful programming, which isn't compliant with the >>>> functional programming concept but, in some cases, can be very useful. >>>> >>>> Hopes it helps, >>>> Rob Stapper >>>> >>>> PS. put the module-file in a subdirectory: "counter", in your >>>> basex-repo-directory. >> >> >> >> -- >> --Marc
RK
Ron Katrielin reply to Christian Grün, 23 Oct 2015, 15:3623 Oct 2015 17:51 #
Hi Cristian, I tried the nested for loops below and it performed as expected (monotonically increasing count). There are a a lot of great enhancements in XQuery 3.0. Thanks for pointing that out! Thanks, Ron
for $n in (1 to 10)[. mod 2 = 1]
for $m in (1 to 10)[. mod 2 = 0]
count $c
return <number count="{ $c }" odd="{ $n }" even="{ $m }"/>
Quoted text · Christian Grün (christian.gruen at gmail.com) · 1 line
On October 23, 2015 at 9:36:35 AM, Christian Grün (christian.gruen at gmail.com) wrote:
Hi Ron, Out of interest: did you have a look at the "count" clause [1]? Christian [1] http://docs.basex.org/wiki/XQuery_3.0#Enhanced_FLWOR_Expressions
Quoted text · Ron Katriel · 66 lines
On Fri, Oct 23, 2015 at 12:02 AM, Ron Katriel <rkatriel at mdsol.com> wrote: > Thanks all! > > I went with the solution suggested by Christian. It is simple, efficient, > and solves my problem (starting at 1 is fine). The GFLWOR approach is nice, > except that I have two nested for loops so it produces two counts instead of > one (and there is no straightforward way to combine them into a single > monotonically increasing number). > > Best, > Ron > > On October 22, 2015 at 5:47:53 AM, Marc van Grootel > (marc.van.grootel at gmail.com) wrote: > > Hi, > > Wouldn't clj-ds [1] be of any help in this? It has support for > transients.I believe that Exist uses this somewhere in their code not > sure where. I think it makes use of these Atomic* objects under the > hood but providing a "functional" facade. btw I'm not speaking from > experience with this library but I do have it on my longlist. > > [1]: https://github.com/krukow/clj-ds > > On Thu, Oct 22, 2015 at 9:38 AM, Christian Grün > <christian.gruen at gmail.com> wrote: >> Hi Rob, >> >> A short variant of your approach could look like this: >> >> import module namespace counter = >> 'java.util.concurrent.atomic.AtomicInteger'; >> for $i in 1 to 10 >> return counter:incrementAndGet() >> >> As you already indicated, it violates the functional programming >> design, so I would surely recommend everyone to use the GFLWOR "at" or >> "count" clause (or possibly fold-left, etc.) >> >> And hi Ron, >> >> Do you need to start with an existing counter when running your query, >> or is it sufficient to start with 1? >> >> Christian >> >> >> On Thu, Oct 22, 2015 at 9:07 AM, Rob Stapper <r.stapper at lijbrandt.nl> >> wrote: >>> Hi Ron, >>> >>> Maybe the attached codes-nippet is useful to you. >>> It is an example of stateful programming, which isn't compliant with the >>> functional programming concept but, in some cases, can be very useful. >>> >>> Hopes it helps, >>> Rob Stapper >>> >>> PS. put the module-file in a subdirectory: "counter", in your >>> basex-repo-directory. > > > > -- > --Marc
RK
Ron Katrielin reply to Christian Grün, 23 Oct 2015, 15:5223 Oct 2015 19:44 #
Thanks, Christian. I am already using maps. Nice to see that the language is actively evolving. Your excellent support is much appreciated! Best, Ron
Quoted text · Christian Grün (christian.gruen at gmail.com) · 1 line
On October 23, 2015 at 9:52:34 AM, Christian Grün (christian.gruen at gmail.com) wrote:
Perfect. Feel free to check out XQuery 3.1 as well: http://docs.basex.org/wiki/XQuery_3.1
Quoted text · Ron Katriel · 100 lines
On Fri, Oct 23, 2015 at 3:53 PM, Ron Katriel <rkatriel at mdsol.com> wrote: > Hi Cristian, > > I tried the nested for loops below and it performed as expected > (monotonically increasing count). > > There are a a lot of great enhancements in XQuery 3.0. Thanks for pointing > that out! > > Thanks, > Ron > > > for $n in (1 to 10)[. mod 2 = 1] > for $m in (1 to 10)[. mod 2 = 0] > count $c > return <number count="{ $c }" odd="{ $n }" even="{ $m }"/> > > > On October 23, 2015 at 9:36:35 AM, Christian Grün > (christian.gruen at gmail.com) wrote: > > Hi Ron, > > Out of interest: did you have a look at the "count" clause [1]? > > Christian > > [1] http://docs.basex.org/wiki/XQuery_3.0#Enhanced_FLWOR_Expressions > > > > On Fri, Oct 23, 2015 at 12:02 AM, Ron Katriel <rkatriel at mdsol.com> wrote: >> Thanks all! >> >> I went with the solution suggested by Christian. It is simple, efficient, >> and solves my problem (starting at 1 is fine). The GFLWOR approach is >> nice, >> except that I have two nested for loops so it produces two counts instead >> of >> one (and there is no straightforward way to combine them into a single >> monotonically increasing number). >> >> Best, >> Ron >> >> On October 22, 2015 at 5:47:53 AM, Marc van Grootel >> (marc.van.grootel at gmail.com) wrote: >> >> Hi, >> >> Wouldn't clj-ds [1] be of any help in this? It has support for >> transients.I believe that Exist uses this somewhere in their code not >> sure where. I think it makes use of these Atomic* objects under the >> hood but providing a "functional" facade. btw I'm not speaking from >> experience with this library but I do have it on my longlist. >> >> [1]: https://github.com/krukow/clj-ds >> >> On Thu, Oct 22, 2015 at 9:38 AM, Christian Grün >> <christian.gruen at gmail.com> wrote: >>> Hi Rob, >>> >>> A short variant of your approach could look like this: >>> >>> import module namespace counter = >>> 'java.util.concurrent.atomic.AtomicInteger'; >>> for $i in 1 to 10 >>> return counter:incrementAndGet() >>> >>> As you already indicated, it violates the functional programming >>> design, so I would surely recommend everyone to use the GFLWOR "at" or >>> "count" clause (or possibly fold-left, etc.) >>> >>> And hi Ron, >>> >>> Do you need to start with an existing counter when running your query, >>> or is it sufficient to start with 1? >>> >>> Christian >>> >>> >>> On Thu, Oct 22, 2015 at 9:07 AM, Rob Stapper <r.stapper at lijbrandt.nl> >>> wrote: >>>> Hi Ron, >>>> >>>> Maybe the attached codes-nippet is useful to you. >>>> It is an example of stateful programming, which isn't compliant with the >>>> functional programming concept but, in some cases, can be very useful. >>>> >>>> Hopes it helps, >>>> Rob Stapper >>>> >>>> PS. put the module-file in a subdirectory: "counter", in your >>>> basex-repo-directory. >> >> >> >> -- >> --Marc
CG
Christian Grünin reply to Ron Katriel, 28 Oct 2015, 18:2828 Oct 2015 17:32 #
Hi Ron, I don't have the CTGov database on my machine… Could you build us a little self-contained example? Thanks in advance, Christian
Quoted text · Ron Katriel · 45 lines
On Wed, Oct 28, 2015 at 5:31 PM, Ron Katriel <rkatriel at mdsol.com> wrote: > Hi, > > When serializing XML to CSV, special characters (e.g., &amp;) are not > converted to their textual representations (e.g., ‘&’). > > For example, the code below outputs > > conditionid nctid condition > 1 NCT00130377 Cardiovascular System Diseases (&amp; [Cardiac]) > > vs. the expected > > conditionid nctid condition > 1 NCT00130377 Cardiovascular System Diseases (& [Cardiac]) > > This seems like a bug. Am I missing an option? I did not see anything > related in the documentation. > > Thanks, > Ron > > > let $options := map { 'lax': false(), 'quotes' : false(), 'separator' : > 'tab', 'header' : true() } > > return file:write('conditions.tsv', > csv:serialize( > <matches> { > for $article in db:open('CTGov')/clinical_study > where $article//nct_id = 'NCT00130377' > for $condition in $article/condition > count $c > return > <match> > <conditionid> { $c } </conditionid>, > <nctid> { normalize-space($article/id_info/nct_id/text()) } > </nctid>, > <condition> { normalize-space($condition/text()) } </condition> > </match> } > </matches>, > $options) > ) > >
CG
Christian Grünin reply to Ron Katriel, 28 Oct 2015, 18:3928 Oct 2015 17:48 #
I guess you'll simply have to use file:write-text instead of file:write (which serializes texts with the default XML output method [1]). [1] http://www.w3.org/TR/xslt-xquery-serialization-31/
Quoted text · Ron Katriel · 67 lines
On Wed, Oct 28, 2015 at 5:42 PM, Ron Katriel <rkatriel at mdsol.com> wrote: > Hi Christian, > > You can use the attached XML file to populate a database. I verified that it > is sufficient to replicate the issue. > > Thanks, > Ron > > > On October 28, 2015 at 12:33:14 PM, Christian Grün > (christian.gruen at gmail.com) wrote: > > Hi Ron, > > I don't have the CTGov database on my machine… Could you build us a > little self-contained example? > > Thanks in advance, > Christian > > > On Wed, Oct 28, 2015 at 5:31 PM, Ron Katriel <rkatriel at mdsol.com> wrote: >> Hi, >> >> When serializing XML to CSV, special characters (e.g., &amp;) are not >> converted to their textual representations (e.g., ‘&’). >> >> For example, the code below outputs >> >> conditionid nctid condition >> 1 NCT00130377 Cardiovascular System Diseases (&amp; [Cardiac]) >> >> vs. the expected >> >> conditionid nctid condition >> 1 NCT00130377 Cardiovascular System Diseases (& [Cardiac]) >> >> This seems like a bug. Am I missing an option? I did not see anything >> related in the documentation. >> >> Thanks, >> Ron >> >> >> let $options := map { 'lax': false(), 'quotes' : false(), 'separator' : >> 'tab', 'header' : true() } >> >> return file:write('conditions.tsv', >> csv:serialize( >> <matches> { >> for $article in db:open('CTGov')/clinical_study >> where $article//nct_id = 'NCT00130377' >> for $condition in $article/condition >> count $c >> return >> <match> >> <conditionid> { $c } </conditionid>, >> <nctid> { normalize-space($article/id_info/nct_id/text()) } >> </nctid>, >> <condition> { normalize-space($condition/text()) } </condition> >> </match> } >> </matches>, >> $options) >> ) >> >>
RK
Ron Katrielin reply to Ron Katriel, 23 Oct 2015, 19:4428 Oct 2015 18:28 #
Hi, When serializing XML to CSV, special characters (e.g., &amp;) are not converted to their textual representations (e.g., ‘&’). For example, the code below outputs conditionid nctid condition 1 NCT00130377 Cardiovascular System Diseases (&amp; [Cardiac]) vs. the expected conditionid nctid condition 1 NCT00130377 Cardiovascular System Diseases (& [Cardiac]) This seems like a bug. Am I missing an option? I did not see anything related in the documentation. Thanks, Ron
let $options := map { 'lax': false(), 'quotes' : false(), 'separator' : 'tab', 'header' : true() }

return file:write('conditions.tsv',
  csv:serialize(
    <matches> {
      for $article in db:open('CTGov')/clinical_study
      where $article//nct_id = 'NCT00130377'
      for $condition in $article/condition
      count $c
      return
        <match>
          <conditionid> { $c } </conditionid>,
          <nctid> { normalize-space($article/id_info/nct_id/text()) } </nctid>,
          <condition> { normalize-space($condition/text()) } </condition>
        </match> }
    </matches>,
    $options)
  )
RK
Ron Katrielin reply to Christian Grün, 28 Oct 2015, 17:3228 Oct 2015 18:39 #
Hi Christian, You can use the attached XML file to populate a database. I verified that it is sufficient to replicate the issue. Thanks, Ron
Quoted text · Christian Grün (christian.gruen at gmail.com) · 1 line
On October 28, 2015 at 12:33:14 PM, Christian Grün (christian.gruen at gmail.com) wrote:
Hi Ron, I don't have the CTGov database on my machine… Could you build us a little self-contained example? Thanks in advance, Christian
Quoted text · Ron Katriel · 45 lines
On Wed, Oct 28, 2015 at 5:31 PM, Ron Katriel <rkatriel at mdsol.com> wrote: > Hi, > > When serializing XML to CSV, special characters (e.g., &amp;) are not > converted to their textual representations (e.g., ‘&’). > > For example, the code below outputs > > conditionid nctid condition > 1 NCT00130377 Cardiovascular System Diseases (&amp; [Cardiac]) > > vs. the expected > > conditionid nctid condition > 1 NCT00130377 Cardiovascular System Diseases (& [Cardiac]) > > This seems like a bug. Am I missing an option? I did not see anything > related in the documentation. > > Thanks, > Ron > > > let $options := map { 'lax': false(), 'quotes' : false(), 'separator' : > 'tab', 'header' : true() } > > return file:write('conditions.tsv', > csv:serialize( > <matches> { > for $article in db:open('CTGov')/clinical_study > where $article//nct_id = 'NCT00130377' > for $condition in $article/condition > count $c > return > <match> > <conditionid> { $c } </conditionid>, > <nctid> { normalize-space($article/id_info/nct_id/text()) } > </nctid>, > <condition> { normalize-space($condition/text()) } </condition> > </match> } > </matches>, > $options) > ) > >
RK
Ron Katrielin reply to Christian Grün, 28 Oct 2015, 17:4828 Oct 2015 19:00 #
Christian, That works. Thanks! Ron
Quoted text · Christian Grün (christian.gruen at gmail.com) · 1 line
On October 28, 2015 at 12:49:06 PM, Christian Grün (christian.gruen at gmail.com) wrote:
I guess you'll simply have to use file:write-text instead of file:write (which serializes texts with the default XML output method [1]). [1] http://www.w3.org/TR/xslt-xquery-serialization-31/
Quoted text · Ron Katriel · 67 lines
On Wed, Oct 28, 2015 at 5:42 PM, Ron Katriel <rkatriel at mdsol.com> wrote: > Hi Christian, > > You can use the attached XML file to populate a database. I verified that it > is sufficient to replicate the issue. > > Thanks, > Ron > > > On October 28, 2015 at 12:33:14 PM, Christian Grün > (christian.gruen at gmail.com) wrote: > > Hi Ron, > > I don't have the CTGov database on my machine… Could you build us a > little self-contained example? > > Thanks in advance, > Christian > > > On Wed, Oct 28, 2015 at 5:31 PM, Ron Katriel <rkatriel at mdsol.com> wrote: >> Hi, >> >> When serializing XML to CSV, special characters (e.g., &amp;) are not >> converted to their textual representations (e.g., ‘&’). >> >> For example, the code below outputs >> >> conditionid nctid condition >> 1 NCT00130377 Cardiovascular System Diseases (&amp; [Cardiac]) >> >> vs. the expected >> >> conditionid nctid condition >> 1 NCT00130377 Cardiovascular System Diseases (& [Cardiac]) >> >> This seems like a bug. Am I missing an option? I did not see anything >> related in the documentation. >> >> Thanks, >> Ron >> >> >> let $options := map { 'lax': false(), 'quotes' : false(), 'separator' : >> 'tab', 'header' : true() } >> >> return file:write('conditions.tsv', >> csv:serialize( >> <matches> { >> for $article in db:open('CTGov')/clinical_study >> where $article//nct_id = 'NCT00130377' >> for $condition in $article/condition >> count $c >> return >> <match> >> <conditionid> { $c } </conditionid>, >> <nctid> { normalize-space($article/id_info/nct_id/text()) } >> </nctid>, >> <condition> { normalize-space($condition/text()) } </condition> >> </match> } >> </matches>, >> $options) >> ) >> >>
RK
Ron Katriel28 Oct 2015 19:34 #
One last question. The serializer has trouble with tags that contain underscores. For example, I get the following error: [bxerr:BXCS0002] CSV serializer: Invalid element name <study_id>. When I remove the underscore the error goes away (I inject these tags in the result clause). Underscores should be fine in XML node names (e.g., clinicaltrials.gov uses them extensively). Is this issue related to the XQuery specification or unique to BaseX? Thanks, Ron
Quoted text · Ron Katriel (rkatriel at mdsol.com) · 1 line
On October 28, 2015 at 12:59:57 PM, Ron Katriel (rkatriel at mdsol.com) wrote:
Christian, That works. Thanks! Ron
Quoted text · Christian Grün (christian.gruen at gmail.com) · 1 line
On October 28, 2015 at 12:49:06 PM, Christian Grün (christian.gruen at gmail.com) wrote:
I guess you'll simply have to use file:write-text instead of file:write (which serializes texts with the default XML output method [1]). [1] http://www.w3.org/TR/xslt-xquery-serialization-31/
Quoted text · Ron Katriel · 67 lines
On Wed, Oct 28, 2015 at 5:42 PM, Ron Katriel <rkatriel at mdsol.com> wrote: > Hi Christian, > > You can use the attached XML file to populate a database. I verified that it > is sufficient to replicate the issue. > > Thanks, > Ron > > > On October 28, 2015 at 12:33:14 PM, Christian Grün > (christian.gruen at gmail.com) wrote: > > Hi Ron, > > I don't have the CTGov database on my machine… Could you build us a > little self-contained example? > > Thanks in advance, > Christian > > > On Wed, Oct 28, 2015 at 5:31 PM, Ron Katriel <rkatriel at mdsol.com> wrote: >> Hi, >> >> When serializing XML to CSV, special characters (e.g., &amp;) are not >> converted to their textual representations (e.g., ‘&’). >> >> For example, the code below outputs >> >> conditionid nctid condition >> 1 NCT00130377 Cardiovascular System Diseases (&amp; [Cardiac]) >> >> vs. the expected >> >> conditionid nctid condition >> 1 NCT00130377 Cardiovascular System Diseases (& [Cardiac]) >> >> This seems like a bug. Am I missing an option? I did not see anything >> related in the documentation. >> >> Thanks, >> Ron >> >> >> let $options := map { 'lax': false(), 'quotes' : false(), 'separator' : >> 'tab', 'header' : true() } >> >> return file:write('conditions.tsv', >> csv:serialize( >> <matches> { >> for $article in db:open('CTGov')/clinical_study >> where $article//nct_id = 'NCT00130377' >> for $condition in $article/condition >> count $c >> return >> <match> >> <conditionid> { $c } </conditionid>, >> <nctid> { normalize-space($article/id_info/nct_id/text()) } >> </nctid>, >> <condition> { normalize-space($condition/text()) } </condition> >> </match> } >> </matches>, >> $options) >> ) >> >>
CG
Christian Grün28 Oct 2015 20:15 #
Quoted text · Ron Katriel · 1 line
> [bxerr:BXCS0002] CSV serializer: Invalid element name <study_id>.
Is there any particular reason why you setting 'lax' to false() [1]? [1] http://docs.basex.org/wiki/CSV_Module
Quoted text · Ron Katriel · 2 lines
> > When I remove the underscore the error goes away (I inject these tags in
the result clause).
Quoted text · Ron Katriel · 2 lines
> > Underscores should be fine in XML node names (e.g., clinicaltrials.gov
uses them extensively).
Quoted text · Ron Katriel · 29 lines
> > Is this issue related to the XQuery specification or unique to BaseX? > > Thanks, > Ron > > On October 28, 2015 at 12:59:57 PM, Ron Katriel (rkatriel at mdsol.com) wrote: >> >> Christian, >> >> That works. Thanks! >> >> Ron >> >> On October 28, 2015 at 12:49:06 PM, Christian Grün ( christian.gruen at gmail.com) wrote: >>> >>> I guess you'll simply have to use file:write-text instead of >>> file:write (which serializes texts with the default XML output method >>> [1]). >>> >>> [1] http://www.w3.org/TR/xslt-xquery-serialization-31/ >>> >>> >>> On Wed, Oct 28, 2015 at 5:42 PM, Ron Katriel <rkatriel at mdsol.com> wrote: >>> > Hi Christian, >>> > >>> > You can use the attached XML file to populate a database. I verified
that it
Quoted text · Ron Katriel · 43 lines
>>> > is sufficient to replicate the issue. >>> > >>> > Thanks, >>> > Ron >>> > >>> > >>> > On October 28, 2015 at 12:33:14 PM, Christian Grün >>> > (christian.gruen at gmail.com) wrote: >>> > >>> > Hi Ron, >>> > >>> > I don't have the CTGov database on my machine… Could you build us a >>> > little self-contained example? >>> > >>> > Thanks in advance, >>> > Christian >>> > >>> > >>> > On Wed, Oct 28, 2015 at 5:31 PM, Ron Katriel <rkatriel at mdsol.com> wrote: >>> >> Hi, >>> >> >>> >> When serializing XML to CSV, special characters (e.g., &amp;) are not >>> >> converted to their textual representations (e.g., ‘&’). >>> >> >>> >> For example, the code below outputs >>> >> >>> >> conditionid nctid condition >>> >> 1 NCT00130377 Cardiovascular System Diseases (&amp; [Cardiac]) >>> >> >>> >> vs. the expected >>> >> >>> >> conditionid nctid condition >>> >> 1 NCT00130377 Cardiovascular System Diseases (& [Cardiac]) >>> >> >>> >> This seems like a bug. Am I missing an option? I did not see anything >>> >> related in the documentation. >>> >> >>> >> Thanks, >>> >> Ron >>> >> >>> >> >>> >> let $options := map { 'lax': false(), 'quotes' : false(),
'separator' :
Quoted text · Ron Katriel · 21 lines
>>> >> 'tab', 'header' : true() } >>> >> >>> >> return file:write('conditions.tsv', >>> >> csv:serialize( >>> >> <matches> { >>> >> for $article in db:open('CTGov')/clinical_study >>> >> where $article//nct_id = 'NCT00130377' >>> >> for $condition in $article/condition >>> >> count $c >>> >> return >>> >> <match> >>> >> <conditionid> { $c } </conditionid>, >>> >> <nctid> { normalize-space($article/id_info/nct_id/text()) } >>> >> </nctid>, >>> >> <condition> { normalize-space($condition/text()) } </condition> >>> >> </match> } >>> >> </matches>, >>> >> $options) >>> >> ) >>> >> >>> >>
RK
Ron Katriel28 Oct 2015 21:47 #
My bad. It was borrowed from an inappropriate example. Removing it eliminates the error. Thanks!
Quoted text · Christian Grün (christian.gruen at gmail.com) · 2 lines
On October 28, 2015 at 3:15:33 PM, Christian Grün (christian.gruen at gmail.com) wrote: > [bxerr:BXCS0002] CSV serializer: Invalid element name <study_id>.
Is there any particular reason why you setting 'lax' to false() [1]? [1] http://docs.basex.org/wiki/CSV_Module
Quoted text · Christian Grün · 94 lines
> > When I remove the underscore the error goes away (I inject these tags in the result clause). > > Underscores should be fine in XML node names (e.g., clinicaltrials.gov uses them extensively). > > Is this issue related to the XQuery specification or unique to BaseX? > > Thanks, > Ron > > On October 28, 2015 at 12:59:57 PM, Ron Katriel (rkatriel at mdsol.com) wrote: >> >> Christian, >> >> That works. Thanks! >> >> Ron >> >> On October 28, 2015 at 12:49:06 PM, Christian Grün (christian.gruen at gmail.com) wrote: >>> >>> I guess you'll simply have to use file:write-text instead of >>> file:write (which serializes texts with the default XML output method >>> [1]). >>> >>> [1] http://www.w3.org/TR/xslt-xquery-serialization-31/ >>> >>> >>> On Wed, Oct 28, 2015 at 5:42 PM, Ron Katriel <rkatriel at mdsol.com> wrote: >>> > Hi Christian, >>> > >>> > You can use the attached XML file to populate a database. I verified that it >>> > is sufficient to replicate the issue. >>> > >>> > Thanks, >>> > Ron >>> > >>> > >>> > On October 28, 2015 at 12:33:14 PM, Christian Grün >>> > (christian.gruen at gmail.com) wrote: >>> > >>> > Hi Ron, >>> > >>> > I don't have the CTGov database on my machine… Could you build us a >>> > little self-contained example? >>> > >>> > Thanks in advance, >>> > Christian >>> > >>> > >>> > On Wed, Oct 28, 2015 at 5:31 PM, Ron Katriel <rkatriel at mdsol.com> wrote: >>> >> Hi, >>> >> >>> >> When serializing XML to CSV, special characters (e.g., &amp;) are not >>> >> converted to their textual representations (e.g., ‘&’). >>> >> >>> >> For example, the code below outputs >>> >> >>> >> conditionid nctid condition >>> >> 1 NCT00130377 Cardiovascular System Diseases (&amp; [Cardiac]) >>> >> >>> >> vs. the expected >>> >> >>> >> conditionid nctid condition >>> >> 1 NCT00130377 Cardiovascular System Diseases (& [Cardiac]) >>> >> >>> >> This seems like a bug. Am I missing an option? I did not see anything >>> >> related in the documentation. >>> >> >>> >> Thanks, >>> >> Ron >>> >> >>> >> >>> >> let $options := map { 'lax': false(), 'quotes' : false(), 'separator' : >>> >> 'tab', 'header' : true() } >>> >> >>> >> return file:write('conditions.tsv', >>> >> csv:serialize( >>> >> <matches> { >>> >> for $article in db:open('CTGov')/clinical_study >>> >> where $article//nct_id = 'NCT00130377' >>> >> for $condition in $article/condition >>> >> count $c >>> >> return >>> >> <match> >>> >> <conditionid> { $c } </conditionid>, >>> >> <nctid> { normalize-space($article/id_info/nct_id/text()) } >>> >> </nctid>, >>> >> <condition> { normalize-space($condition/text()) } </condition> >>> >> </match> } >>> >> </matches>, >>> >> $options) >>> >> ) >>> >> >>> >>

⚡Generated with XQuery