Re: [basex-talk] file:write - check, if path is existing

2016-05-20 Thread kleist-digital
Hi Marc,

thanks for the hint. In my case file:is-dir did it. Thanks again.

Günter

> Am 20.05.2016 um 08:24 schrieb Marc :
> 
> Hi Günter,
> in the file: you have the is-file function.
> Does'nt it do the job?
> Marc
> Le 19/05/2016 à 21:25, Günter Dunz-Wolff a écrit :
>> Hi all,
>> 
>> for the command file:write($path, distinct-values($list)) I have to check, 
>> if $path is existing (for example let $path := ´users/xxx/xxx/etc’.
>> How is it done in XQuery? Thanks for any help.
>> 
>> Cheers,
>> Günter
>> 
> 




Re: [basex-talk] RESTXQ and Website-Building (search-form)

2016-04-12 Thread kleist-digital
Hi Marco,

thanks for the tipps. I’ll try them.

Ciao,
Günter

> Am 12.04.2016 um 09:52 schrieb Marco Lettere <m.lett...@gmail.com>:
> 
> BTW, in BaseX every xqm module containing RestXQ annotated functions and 
> stored inside the webapp folder will be handled as RestXQ entrypoint thus you 
> can write your functions where ever you prefer.
> Ciao,
> M.
> 
> On 12/04/2016 07:51, kleist-digital wrote:
>> Hi Christian, hi Marco,
>> 
>> I checked the docs and I managed a solution, but it’s combined with the more 
>> classical assemble-page approach. [1]
>> 
>> In Marco’s approach using xquery:invoke there is an index.xqm, which handles 
>> all XQuery annotations for RESTXQ. They are all based an %rest:GET, but for 
>> handling forms, I need a %rest:PUT annotation. I can’t figure out, where to 
>> put it. Or in generell: is the index.xqm the only place, where all 
>> annotations are handled?
>> 
>> Comparing the two approaches with the functions assemble-page and 
>> xquery:invoke for me the last one is more intuitive, so it would be nice, to 
>> get it run.
>> 
>> Thanks for help,
>> Günter
>> 
>> [1] https://en.wikibooks.org/wiki/XQuery/Creating_XQuery_Functions
>> 
>>> Am 11.04.2016 um 19:57 schrieb Christian Grün <christian.gr...@gmail.com>:
>>> 
>>> Hi Günter,
>>> 
>>> I recommend you to check out our RESTXQ documentation [1], and the
>>> example you get displayed after starting basexhttp and visiting
>>> http://localhost:8984/. In the next step, the DBA code should give you
>>> many helpful hints (but it may be too advanced to start off with).
>>> 
>>> Hope this helps
>>> Christian
>>> 
>>> [1] http://docs.basex.org/wiki/RESTXQ
>>> 
>>> 
>>> 
>>> On Mon, Apr 11, 2016 at 3:50 PM, kleist-digital
>>> <kle...@mail.dunzwolff.de> wrote:
>>>> Hi Marco,
>>>> 
>>>> one problem I achieved: how to handle a simple search-form with your 
>>>> approach or with RESTXQ in generell?
>>>> 
>>>> I have to modules: search.xqm and results.xqm.
>>>> - How do I have to handle the RESTXQ-Annotations in index.xqm and or 
>>>> searchxqm, so that the query-params are transferred to results.xqm?
>>>> - What kind if form-action is necessary to get from /search to /results?
>>>> 
>>>> I tried different things, but didn’t succeed. Perhaps you have an advice? 
>>>> Thanks in advance.
>>>> 
>>>> Herzlich gegruesst,
>>>> Günter
>>>> 
>>>>> Am 10.04.2016 um 22:36 schrieb Marco Lettere <m.lett...@gmail.com>:
>>>>> 
>>>>> Hi Günter,
>>>>> sorry for the delay but here you go with a very small example that should 
>>>>> show off what I told.
>>>>> You can copy the .xqm files into the webapp dir of a basex installation 
>>>>> and and the .css files into the corresponding static folder.
>>>>> Then invoke the "entrypoint" RestXQ from within your browser with an url 
>>>>> similar to
>>>>> 
>>>>> http://localhost:8984/myapp/page1?user=Marco
>>>>> 
>>>>> As you can see the HTML page built from the entrypoint is composed of 
>>>>> three parts. One that selects the styles to apply according to the user 
>>>>> being anonymous or not.
>>>>> Then a common header markup is generated and finally a dynamic part that 
>>>>> depends on the page element of the path.
>>>>> 
>>>>> It's really not anything special but nevertheless it should be useful in 
>>>>> clarifying the approach.
>>>>> 
>>>>> Hoffe es gefaellt dir.
>>>>> Herzliche Gruesse,
>>>>> Marco.
>>>>> 
>>>>> On 10/04/2016 17:36, Günter Dunz-Wolff wrote:
>>>>>> Hi Marco,
>>>>>> 
>>>>>> it’s me again. Just to be more specific, I’m especially interested in 
>>>>>> your approach
>>>>>> - to pass parametric values into the „exploded“ modules
>>>>>> - to map requests to module invocations by exploiting REST path segments
>>>>>> 
>>>>>> It would be really helpful, to get some snippets of your code. Tanks a 
>>>>>> lot.
>>>>>> 
>>>>>> Ciao, Günter
>>>>>> 
>>>>>>&g

Re: [basex-talk] RESTXQ and Website-Building (search-form)

2016-04-11 Thread kleist-digital
Hi Christian, hi Marco,

I checked the docs and I managed a solution, but it’s combined with the more 
classical assemble-page approach. [1]

In Marco’s approach using xquery:invoke there is an index.xqm, which handles 
all XQuery annotations for RESTXQ. They are all based an %rest:GET, but for 
handling forms, I need a %rest:PUT annotation. I can’t figure out, where to put 
it. Or in generell: is the index.xqm the only place, where all annotations are 
handled?

Comparing the two approaches with the functions assemble-page and xquery:invoke 
for me the last one is more intuitive, so it would be nice, to get it run.

Thanks for help,
Günter

[1] https://en.wikibooks.org/wiki/XQuery/Creating_XQuery_Functions

> Am 11.04.2016 um 19:57 schrieb Christian Grün <christian.gr...@gmail.com>:
> 
> Hi Günter,
> 
> I recommend you to check out our RESTXQ documentation [1], and the
> example you get displayed after starting basexhttp and visiting
> http://localhost:8984/. In the next step, the DBA code should give you
> many helpful hints (but it may be too advanced to start off with).
> 
> Hope this helps
> Christian
> 
> [1] http://docs.basex.org/wiki/RESTXQ
> 
> 
> 
> On Mon, Apr 11, 2016 at 3:50 PM, kleist-digital
> <kle...@mail.dunzwolff.de> wrote:
>> Hi Marco,
>> 
>> one problem I achieved: how to handle a simple search-form with your 
>> approach or with RESTXQ in generell?
>> 
>> I have to modules: search.xqm and results.xqm.
>> - How do I have to handle the RESTXQ-Annotations in index.xqm and or 
>> searchxqm, so that the query-params are transferred to results.xqm?
>> - What kind if form-action is necessary to get from /search to /results?
>> 
>> I tried different things, but didn’t succeed. Perhaps you have an advice? 
>> Thanks in advance.
>> 
>> Herzlich gegruesst,
>> Günter
>> 
>>> Am 10.04.2016 um 22:36 schrieb Marco Lettere <m.lett...@gmail.com>:
>>> 
>>> Hi Günter,
>>> sorry for the delay but here you go with a very small example that should 
>>> show off what I told.
>>> You can copy the .xqm files into the webapp dir of a basex installation and 
>>> and the .css files into the corresponding static folder.
>>> Then invoke the "entrypoint" RestXQ from within your browser with an url 
>>> similar to
>>> 
>>> http://localhost:8984/myapp/page1?user=Marco
>>> 
>>> As you can see the HTML page built from the entrypoint is composed of three 
>>> parts. One that selects the styles to apply according to the user being 
>>> anonymous or not.
>>> Then a common header markup is generated and finally a dynamic part that 
>>> depends on the page element of the path.
>>> 
>>> It's really not anything special but nevertheless it should be useful in 
>>> clarifying the approach.
>>> 
>>> Hoffe es gefaellt dir.
>>> Herzliche Gruesse,
>>> Marco.
>>> 
>>> On 10/04/2016 17:36, Günter Dunz-Wolff wrote:
>>>> Hi Marco,
>>>> 
>>>> it’s me again. Just to be more specific, I’m especially interested in your 
>>>> approach
>>>> - to pass parametric values into the „exploded“ modules
>>>> - to map requests to module invocations by exploiting REST path segments
>>>> 
>>>> It would be really helpful, to get some snippets of your code. Tanks a lot.
>>>> 
>>>> Ciao, Günter
>>>> 
>>>>> Am 08.04.2016 um 10:13 schrieb Marco Lettere <m.lett...@gmail.com>:
>>>>> 
>>>>> Hi Günter,
>>>>> we have worked on several web applications that include a frontend and we 
>>>>> are very happy with using basex for serving both static (scripts, css, 
>>>>> images) and dynamic (markup) content.
>>>>> One pattern that we've used often and that we find very productive is to 
>>>>> split markup content into different .xqm modules.
>>>>> The modules are called through the xquery:invoke function in order to 
>>>>> "explode" their output into the main page.
>>>>> In our opinion this is a good approach because it is applicable 
>>>>> recursively to sub-modules. Content of modules may be dynamic as well and 
>>>>> parametric values are passed into the module through external variables.
>>>>> Finally, it is possible to set up an automatic way of mapping requests to 
>>>>> module invocations by exploiting REST path segments for example.
>>>>> I hope I have been able to explain 

Re: [basex-talk] RESTXQ and Website-Building (search-form)

2016-04-11 Thread kleist-digital
Hi Marco,

one problem I achieved: how to handle a simple search-form with your approach 
or with RESTXQ in generell?

I have to modules: search.xqm and results.xqm. 
- How do I have to handle the RESTXQ-Annotations in index.xqm and or searchxqm, 
so that the query-params are transferred to results.xqm?
- What kind if form-action is necessary to get from /search to /results?

I tried different things, but didn’t succeed. Perhaps you have an advice? 
Thanks in advance.

Herzlich gegruesst,
Günter

> Am 10.04.2016 um 22:36 schrieb Marco Lettere <m.lett...@gmail.com>:
> 
> Hi Günter,
> sorry for the delay but here you go with a very small example that should 
> show off what I told.
> You can copy the .xqm files into the webapp dir of a basex installation and 
> and the .css files into the corresponding static folder.
> Then invoke the "entrypoint" RestXQ from within your browser with an url 
> similar to
> 
> http://localhost:8984/myapp/page1?user=Marco
> 
> As you can see the HTML page built from the entrypoint is composed of three 
> parts. One that selects the styles to apply according to the user being 
> anonymous or not.
> Then a common header markup is generated and finally a dynamic part that 
> depends on the page element of the path.
> 
> It's really not anything special but nevertheless it should be useful in 
> clarifying the approach.
> 
> Hoffe es gefaellt dir.
> Herzliche Gruesse,
> Marco.
> 
> On 10/04/2016 17:36, Günter Dunz-Wolff wrote:
>> Hi Marco,
>> 
>> it’s me again. Just to be more specific, I’m especially interested in your 
>> approach
>> - to pass parametric values into the „exploded“ modules
>> - to map requests to module invocations by exploiting REST path segments
>> 
>> It would be really helpful, to get some snippets of your code. Tanks a lot.
>> 
>> Ciao, Günter
>> 
>>> Am 08.04.2016 um 10:13 schrieb Marco Lettere <m.lett...@gmail.com>:
>>> 
>>> Hi Günter,
>>> we have worked on several web applications that include a frontend and we 
>>> are very happy with using basex for serving both static (scripts, css, 
>>> images) and dynamic (markup) content.
>>> One pattern that we've used often and that we find very productive is to 
>>> split markup content into different .xqm modules.
>>> The modules are called through the xquery:invoke function in order to 
>>> "explode" their output into the main page.
>>> In our opinion this is a good approach because it is applicable recursively 
>>> to sub-modules. Content of modules may be dynamic as well and parametric 
>>> values are passed into the module through external variables.
>>> Finally, it is possible to set up an automatic way of mapping requests to 
>>> module invocations by exploiting REST path segments for example.
>>> I hope I have been able to explain it well enough otherwise, just let me 
>>> know and as soon as possible I'll provide an example code snippet that 
>>> demonstrates the approach.
>>> 
>>> Ciao,
>>> Marco.
>>> 
>>> On 07/04/2016 17:08, Günter Dunz-Wolff wrote:
>>>> Hi,
>>>> 
>>>> I'm planning to relaunch my website (kleist-digital.de) with OpenShift as 
>>>> BaseX-Server. After some difficulties and a lot of help from Christian and 
>>>> Andy the server is running now.
>>>> 
>>>> I took a look at RESTXQ and it seems quite interesting to build the whole 
>>>> frontend for my app with it. Some questions I have:
>>>> 
>>>> 1. I'm working with a basic layout for all pages. This basic layout-file 
>>>> includes header, footer and changing content. What is the best approach 
>>>> with RESTXQ. How to build a modular concept with RESTXQ?
>>>> 
>>>> 2. Is there any site-structure preferred?
>>>> 
>>>> 3. Most of the site is dynamic. But I need also static files like images, 
>>>> css, javascript. Where to put them best (so that the Openshift-Server can 
>>>> handle them)?
>>>> 
>>>> Thanks for any advice and help.
>>>> 
>>>> Günter
>>> 
> 
> 




[basex-talk] node-basex

2016-04-03 Thread kleist-digital
Hi Andy,

me again. Just saw, that you’ve also written a node-based Basex-Client. My 
frontend is a node-app. So far I’m using AJAX-calls, to communicate via the 
REST-Interface with the Basex-Server, in generell I use the run command to 
execute different queries.

Are there any advantages (disadvantages) to change to a classical Server-Client 
Scenario (performance, less resources, security)? You know, I want to use it in 
an OpenShift-Environment for the future.

Thanks for any advice.

Günter


Re: [basex-talk] [ANN] Openshift BaseX quick start v0.6

2016-04-02 Thread kleist-digital
Hi Andy,

my modules are now in basex repo and everything works fine, locally and on the 
remote server and for the first time I did my data back from the server :))

But I have problems with updating the data.

> > changing the data in the folder first-data and the db will be recreated 
> > after pushing it to the server.
> Deleting the active users.xml file in the openshift data folder will trigger 
> the copying the contents of  first-data to data at the next push. 

Perhaps I didn’t unterstand the workflow, here is, what I did

1. I copied updated db-files to first-data in my local directory.
2. After git add and commit I pushed the data to the server: git push origin 
master
3. Now the updated files are in first-data on the server. The old ones are in 
basex data.
4. Then in basex data I did: rm users.xml
5. Locally I did a little change in users.xml to get after a commit an 
opportunity for a new git push origin master, what I did.
6.  The new users.xml was copied to server first-data, but nothing else 
changed. The triggering of copying the contents of first-data to data didn’t 
happen. There is no more users.xml in basex data.

What did I wrong, or what did I misunderstood?

Günter




> Am 31.03.2016 um 23:32 schrieb Andy Bunce <bunce.a...@gmail.com>:
> 
> Günter,
> 
> >I tried a lot of path-variations for " at '../modules/kleist-functions.xqm' 
> >", but none succeeded.
> 
> I am not a user of the REST interface so I cant help much but I would expect 
> the same folder structure to work on openshift as on your local machine. Have 
> you compared the dba values for RESTPATH  etc on the two hosts? 
> 
> Relative paths are resolved against RESTPATH  which, using the above, leads 
> to modules being a sibling not a child of webapp .
> 
> > changing the data in the folder first-data and the db will be recreated 
> > after pushing it to the server.
> Deleting the active users.xml file in the openshift data folder will trigger 
> the copying the contents of  first-data to data at the next push. 
> 
> /Andy
> 
> On 31 March 2016 at 21:18, Günter Dunz-Wolff <kle...@mail.dunzwolff.de> wrote:
> Hi Andy,
> 
> thx, I got it. Now it's running. But if in the query is an imported 
> namespace, for example
> 
> import module namespace kleist = "http://kleist-digital.de/ns/kleist; at 
> "../modules/kleist-functions.xqm";
> 
> then with
> 
> curl -i "https://xxx-xxx.rhcloud.com/rest?run=xqs/list_ba_flyer.xq;
> 
> I'll get
> 
> Could not retrieve module: 
> /var/lib/openshift/xxx/app-root/modules/kleist-functions.xqm
> 
> I tried a lot of path-variations for " at '../modules/kleist-functions.xqm' 
> ", but none succeeded.
> 
> The file-structure is as following:
> - webapp
> -- modules
> ---kleist-functions.xqm
> -- xqs
> --- list_ba_flyer.xq
> 
> Thanks for any advice.
> 
> One more thing, hopefully the last one ;-)
> 
> My data are changing a lot, so I have to recreate my basex-db again and 
> again. Locally it's no problem, I'm doing it with BaseX GUI. But is there a 
> convenient way for doing it with the remote server? Like changing the data in 
> the folder first-data and the db will be recreated after pushing it to the 
> server. Or do I have to re-install the whole app after changing the data?
> 
> Thanks a lot for your advices,
> Best, Günter
> 
> > Am 31.03.2016 um 19:45 schrieb Andy Bunce <bunce.a...@gmail.com>:
> >
> > Hi Günter,
> >
> > >I also copied my xq-files via repo
> > >On the Server the file is copied to 
> > >/var/lib/openshift/xxx/app-root/data/basex/repo/xqs/list_ba_flyer.xq
> >
> > I think using repo is the problem. This is intended for special packages 
> > and modules only.
> >
> > If you look at the right side of dba/databases page you should see 
> > something like:
> >
> > REPOPATH 
> > /var/lib/openshift/56fc4cce2d5271f29121/app-root/data/basex/repo
> > RESTPATH
> > RESTXQPATH
> > ..
> > WEBPATH 
> > /var/lib/openshift/56fc4cce2d5271f29121/app-root/data/basex/webapp
> >
> > For resolving REST run paths RESTPATH is used. This is unset in the default 
> > configuration - so WEBPATH is used
> > (see http://docs.basex.org/wiki/Options#RESTPATH )
> >
> > So if you create a xqs folder below webapp and put list_ba_flyer.xq there 
> > then it should work.
> >
> > Regarding the database loading zips my documentation is again a bit lacking 
> > here. I meant if you have created a basex database backup using the dba or 
> > the gui and place the resulting zip here. (The name would look like 
> > factbook-2

[basex-talk] BaseX XQuery Validation in Oxygen

2016-04-02 Thread kleist-digital
Hi all, hi Christian,

in BaseX-specific cases, the Oxygen XQuery-Validation doesn’t work based on the 
Saxon-Engine, for example

import module namespace kleist = "http://kleist-digital.de/ns/kleist“;

gives feedback: Failed to resolve URI of imported module: Cannot locate module 
for namespace http://kleist-digital.de/ns/kleist

Is there any way, to use the basex-XQuery-Parser inside of Oxygen?

Best regards,
Günter




Re: [basex-talk] Problem with module-import via relative / absolute path (WEBPATH, REST-Interface)

2016-04-01 Thread kleist-digital
Hi Christian,

thanks for the tipp. I tried, but get the message "Module not found: 
http://kleist-digital.de/ns/kleist“

The working solution with absolute path is:
import module namespace kleist = "http://kleist-digital.de/ns/kleist; at 
"file:///Users/gdunzwolff/Documents/kleist/BaseXWeb/modules/kleist-functions.xqm“;

My RepoPath is:
REPOPATH = /Applications/basex/repo

The module is now in Applications/basex/repo and is called kleist-functions.xqm.
In the module importing file the header is: 
import module namespace kleist = "http://kleist-digital.de/ns/kleist“;

With http://localhost/rest?run=xqs/list_ba_flyer.xq I get
Module not found: http://kleist-digital.de/ns/kleist. There is no more ask for 
kleist-functions.xqm.

How do I have to name the module in repo, so that it will be found. Or do I 
have to change the import-statement?

Günter

> Am 01.04.2016 um 17:58 schrieb Christian Grün <christian.gr...@gmail.com>:
> 
> Hi Günter,
> 
> You may be generally better off moving all your modules to the repo
> directory. This way, there will be no need anymore to specify the
> module location. Did you already think about it?
> 
> Christian
> 
> 
> On Fri, Apr 1, 2016 at 12:26 PM, Günter Dunz-Wolff
> <kle...@mail.dunzwolff.de> wrote:
>> Hi all,
>> 
>> in my queries I have to import module namespace, for example in the file 
>> test.xq something like
>> import module namespace kleist = "http://kleist-digital.de/ns/kleist; at 
>> "../modules/kleist-functions.xqm";
>> 
>> I'm calling the query via REST like
>> http://localhost/rest?run=xqs/test.xq
>> 
>> The webpath is configured like
>> # HTTP Services
>> WEBPATH = /Users/xxx/Documents/kleist/BaseXWeb
>> RESTPATH =
>> 
>> When I'm using the absolute path, everything works fine:
>> import module namespace kleist = "http://kleist-digital.de/ns/kleist; at 
>> "file:///Users/xxx/Documents/kleist/BaseXWeb/modules/kleist-functions.xqm";
>> 
>> When I'm using the relative path for importing the module namespace like
>> import module namespace kleist = "http://kleist-digital.de/ns/kleist; at 
>> "../modules/kleist-functions.xqm";
>> I'll get the following error:
>> "Could not retrieve module: /Users/modules/kleist-functions.xqm"
>> The correct address should be: 
>> Users/xxx/Documents/kleist/BaseXWeb/modules/kleist-functions.xqm
>> 
>> What's wrong in my configuration? Btw, I need the relative path for 
>> portability to my remote server.
>> 
>> Any help would be great, thanks a lot,
>> Best regards, Günter
> 




[basex-talk] How to get the complete list of full-text-index

2016-01-12 Thread kleist
Hi all, hi Christian

is there any way to get the complete list of the full-text-index? With the GUI 
I only get the first part:

- Names: 
- Size: 5 MB
- Entries: 23401
  und   22662x
  der   20595x


Thanks in advance.

Best regards,
Günter


Re: [basex-talk] How to get the complete list of full-text-index

2016-01-12 Thread kleist
Perhaps I don't get it, that command gives me the number of a specific term? 
But I need the list of all terms (with number of occurences).

Best, Günter

> Am 12.01.2016 um 21:39 schrieb Christian Grün :
> 
>> is there any way to get the complete list of the full-text-index?
> 
> Yes there is [1]. Check out all other functions in the Full-Text
> Module; they may help you in various other situations.
> 
> Cheers,
> Christian
> 
> [1] http://docs.basex.org/wiki/Full-Text_Module#ft:tokens
> 
> 
> With the GUI I only get the first part:
>> 
>> - Names:
>> - Size: 5 MB
>> - Entries: 23401
>>  und   22662x
>>  der   20595x
>> 
>> 
>> Thanks in advance.
>> 
>> Best regards,
>> Günter
> 




[basex-talk] Fulltext-Search: wildcards and thesaurus

2016-01-12 Thread kleist
Hi all, hi Christian,

is it possible to combine wildcards and thesaurus in a fulltext-search, for 
example:

contains text "nachricht.*" using wildcards using thesaurus at "thesaurus.xml"

Best regards,
Günter


[basex-talk] Fulltext Stemming

2016-01-10 Thread kleist
Hi all,

with query options:
contains text "grün" all using diacritics sensitive using stemming using 
language 'German'

I'll get: "grüne", "grüner", "Grüns" etc.

But I also get  "Gruß", "Grüße", "grüßen" or something like "Gruner" (Eigenname)

Does the stemming have problems with german umlaute and "ß"?

with query options:
contains text "grün" all using stemming using language 'German'
same results, but less. Why is that?

The indexes of the database are the following:
Indexes
 Up-to-date: true
 TEXTINDEX: true
 ATTRINDEX: true
 FTINDEX: true
 TEXTINCLUDE: 
 ATTRINCLUDE: 
 FTINCLUDE: 
 LANGUAGE: German
 STEMMING: true
 CASESENS: true
 DIACRITICS: true
 STOPWORDS: 
 UPDINDEX: false
 AUTOOPTIMIZE: false
 MAXCATS: 100
 MAXLEN: 96
 INDEXSPLITSIZE: 0
 FTINDEXSPLITSIZE: 0

Optimized Query is the following:
Optimized Query:
let $hits_137 := ft:mark((db:open-pre("kleist-searchindex",147544), 
...)/(((descendant::tei:s union descendant::tei:l)))[descendant::text() 
contains text "grün" all using diacritics sensitive using stemming using 
language 'German']) return element div { (element p { ("grün") }, element p { 
(count($hits_137)) }, element ul { (for $hit_139 in $hits_137 return element li 
{ 
($hit_139/descendant-or-self::node()/ancestor::tei:TEI/descendant-or-self::node()/tei:classCode[position()
 = 1]/string(), $hit_139) }) }) }

Best, Günter




Re: [basex-talk] XQuery Update: remove-elements-not-contents

2016-01-08 Thread kleist-digital
Hi Christian,

here’s my code:

let $input := "
u.und

für
die
Folge
da
werden
Sie,

   Gnädigstegnädigste
   
   Tante,

Anmerkungstext
schon
sorgen.
“

let $xml := parse-xml($input)
return $xml update (
  for $s in s
   return (delete node .//(note|reg), 
   replace value of node $s with normalize-space($s))
)

The output is:
u.und für die Folge da werden Sie, Gnädigstegnädigste Tante, Anmerkungstext 
schon sorgen.

The query does the replacement, but not the deletion.

In my app currently I’m building two new indices, the first one with deletion, 
based on that one the replacement. It would be nice, to combine it in one query.

Btw., searching in my App with the new final index is a pleasure. It’s much 
faster than ever before (mostly under or near one second in browser) and 
completely with mark-elements tagged. Great! Thanks for your great support.

Best, Günter

> Am 07.01.2016 um 11:31 schrieb Christian Grün <christian.gr...@gmail.com>:
> 
> Could you possibly copy and paste the query I send to you in my last
> response, and modify it that it allows me to reproduce the problem
> out-of-the-box?
> 
> 
> On Thu, Jan 7, 2016 at 11:29 AM, kleist-digital
> <kle...@mail.dunzwolff.de> wrote:
>> 
>>http://www.tei-c.org/ns/1.0; 
>> xmlns:xi="http://www.w3.org/2001/XInclude; xml:id="N111A6">JeztJetzt darf 
>> ich zu dem Mittel meine Zuflucht noch nicht ergreifen nehmen, u.und für die 
>> Folge da werden Sie, Gnädigstegnädigste Tante, schon sorgen.
>>http://www.tei-c.org/ns/1.0; 
>> xmlns:xi="http://www.w3.org/2001/XInclude; xml:id="N111A6">JeztJetzt darf 
>> ich zu dem Mittel meine Zuflucht noch nicht ergreifen nehmen, u.und für die 
>> Folge da werden Sie, Gnädigstegnädigste Tante, schon sorgen.
>>  
>> 
>> The query is
>> db:create('kleist_index_search‘,
>>for $item in db:open('kleist-data‘)
>>return $item update
>>(delete node .//(tei:note|tei:rdg|tei:lb|tei:del|tei:reg|tei:sic),
>>for $s in .//tei:s
>>return replace value of node $s with normalize-space($s)),
>> db:open('kleist-data')/db:path(.))
> 




[basex-talk] XQuery Update: remove-elements-not-contents

2016-01-06 Thread kleist
Hi Christian, hello all,

to write a new index to get better results out of mostly mixed-content 
elements, I have to delete some elements:

db:create('index', for $item in db:open('data') return $item update delete node 
.//(note|sic), db:open('data')/db:path(.))

After that I have to remove some elements, but not the content, like the 
FunctX-function functx:remove-elements-not-contents does
(http://www.xqueryfunctions.com/xq/functx_remove-elements-not-contents.html), 

to get
This is only an illustrative example, not a real text.
from
This is only an illustrative example, not a real text.

Is there any way, to do it with the help of BaseX XQuery Update?

Best regards, Günter





[basex-talk] Error Java ArrayIndexOutOfBoundsException

2016-01-06 Thread kleist
Hello again,

I got the following error:

Error:
Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk@mailman.uni-konstanz.de
Version: BaseX 8.3.1
Java: Oracle Corporation, 1.8.0_45
OS: Mac OS X, x86_64
Stack Trace: 
java.lang.ArrayIndexOutOfBoundsException

after running:

xquery version "3.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0;;
db:create('kleist_index', for $item in db:open('kleist-data') return $item 
update delete node .//(tei:note|tei:rdg|tei:lb|tei:del|tei:reg|tei:sic), 
db:open('kleist-data')/db:path(.))

This error only appears on my second computer (both MacBooks). The one, which 
works, runs 
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

the other, where my xq is not working java version "1.8.0_45" (Java 8-Update 
66).

Any ideas, what's the problem?

Best, Günter


[basex-talk] ft:search and map-function

2016-01-05 Thread kleist
Hi all,

in the documentation for the ft:search-function is the following example:

ft:search("db", ("A", "B"), map {
  "mode": "all words",
  "distance": {
"max": "5",
"unit": "words"
  }
})

It's throwing this error for line 3:  "Invalid value, simple expression 
expected." I'm using BaseX Version 8.3.1. Did the notation change or what's 
going wrong?

Best regards,
Günter


Re: [basex-talk] XQery Performance-Problem when using variables

2016-01-05 Thread kleist
Hi Christian,

I refactored my xquery and it's now running very smooth, faster than ever. 
Thanks a lot for your great help. I also followed your advice, creating a new 
index just for the full-text-search in mixed-content-environments. This 
approach is solving a lot of problems I had in the past... Thanks again.

I want to use also your programmatic way to specify full-text options only once 
in the query, cause it would make my code much cleaner:

let $ft := map { 'wildcards': true() }
let $terms := 'pa.*'
for $city in ft:search('factbook', $terms, $ft)/parent::name[ancestor::city]
let $hits := ft:mark($city[ft:contains(text(), $terms, $ft)])
return
let $name := $city/ancestor::country/name
return ($hits, $name)

The $options argument in ft:search has most the full-text options, I need. The 
only problem left is, to integrate the full-text options 'case sensitive' and 
'diacritics sensitive'. Is there any way, to get those options inside the 
ft:search function?

Günter



> Am 05.01.2016 um 19:56 schrieb Christian Grün :
> 
> Hi Günter,
> 
> I had one more look at the slow query you were encountering:
> 
>> for $city in doc('factbook')//city/name
>> for $hits in ft:mark($city[.//text() contains text {$query} using wildcards])
>> let $country_of_city := $city/ancestor::country/name
>> return
>> (: slow version: Evaluating 35.78 :)
>> (: {$hits}{$country_of_city} :)
> 
> This one was more tricky than I expected, because the ft:mark function
> can produce multiple results for a single node. This is why the
> sliding of the let clause, which slows down your query, can be
> beneficial in other cases. The following query will generate 20
> results (10 "mark" elements, 10 text nodes), so it will be evaluated
> faster if the let clause is slided over the for clause:
> 
>  let $input := ({ 'A.A.A.A.A.A.A.A.A.A.' } update () )/text()
>  for $hits in ft:mark($input[. contains text 'A'])
>  let $parent := $input/..
>  return { $hits }
> 
> Well, those are lots of internal details that I think you can easily
> ignore. In a nutshell: Just use 'let' and 'where' instead tof 'for':
> 
>  let $input := ({ 'A.A.A.A.A.A.A.A.A.A.' } update () )/text()
>  let $hits := ft:mark($input[. contains text 'A'])
>  where $hits
>  let $parent := $input/..
>  return { $hits }
> 
> Christian
> 




[basex-talk] AWS Deployment, .war-file writing

2016-01-04 Thread kleist
Hi all,

I want to deploy my baxex-App to Amazon Web Services (AWS). Therefore I need a 
.war file of my existing application, not only the war-file of basex. How can I 
do it?

There is the excellent tutorial of Paul Swennenhuis about Deployment on AWS 
(Part II). But it's a little bit outdated. AWS is now using tomcat 8 and it is 
no more stored at /var/lib/tomcat... Does anybody know, where I can find the 
new root-directory?

Thanks for any help,
Günter


Re: [basex-talk] XQery Performance-Problem when using variables

2016-01-04 Thread kleist
Dear Christian,

thanks a lot for your help. Now I have lots of stuff to think about and to 
implement.

Best, Günter

> Am 04.01.2016 um 02:29 schrieb Christian Grün :
> 
> By the way, here are two more rewritings to avoid the current sliding
> of the let clause:
> 
> Variant A:
>  for $city in doc('factbook')//city/name
>  let $hits := ft:mark($city[text() contains text 'paris'])
>  where $hits
>  let $name := $city/ancestor::country/name
>  return ($hits, $name)
> 
> Variant B:
>  for $city in doc('factbook')//city/name
>  for $hits in ft:mark($city[text() contains text 'paris'])
>  return
>let $name := $city/ancestor::country/name
>return ($hits, $name)
> 
> And here is one more programmatic way to specify full-text options
> only once in the query:
> 
>  let $ft := map { 'wildcards': true() }
>  let $terms := 'pa.*'
>  for $city in ft:search('factbook', $terms, $ft)/
>parent::name[ancestor::city]
>  let $hits := ft:mark($city[ft:contains(text(), $terms, $ft)])
>  return
>let $name := $city/ancestor::country/name
>return ($hits, $name)
> 
> This variant is clearly the most verbose one, but it may turn out to
> be the favorite once you want to specify a lot more full-text options
> more than once.
> 
> 
> 
> On Sun, Jan 3, 2016 at 12:44 PM, Christian Grün
>  wrote:
 let $query := "Paris"
 for $city in doc('factbook')//city/name[text() contains text {$query}]
 return ft:mark($city)
>>> 
>>> doesn't return the 'mark'-tags
>> 
>> Sorry, should have been like that:
>> 
>>  let $query := "Paris"
>>  for $city in doc('factbook')//city/name[text() contains text {$query}]
>>  return ft:mark($city[text() contains text {$query}])
> 




Re: [basex-talk] XQery Performance-Problem when using variables

2016-01-03 Thread kleist
Hi Christian,

thanks a lot for your advice, but sorry, but I don't really get it so far.

Your code

>  let $query := "Paris"
>  for $city in doc('factbook')//city/name[text() contains text {$query}]
>  return ft:mark($city)

doesn't return the 'mark'-tags, which are important for me and where are you 
applying the search condition twice? Also I'm depending on information about 
the ancestor-node (country). Perhaps, I got it totally wrong.

About your one more thing ;-)

> And one more thing:
> 
>> { if ($ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="short"]) then 
>> $ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="short"]/string()
>>else if 
>> ($ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="article"]) then 
>> $ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="article"]/string()
>>else if 
>> ($ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="main"]) then 
>> $ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="main"]/string()
> 
> This code will most probably be executed faster if you only do the
> path traveral once, e.g. as follows:
> 
>  let $title := $ele/ancestor::tei:TEI//tei:titleStmt/tei:title
> [@type = ('short', 'article', 'main')]/string()
>  ...
>  return $title

I tried it and it's reducing the evaluation-time by half (ca. 16000ms). But if 
I don't use the let clause and return your code directly, the evaluation time 
goes down to 588ms!!

Best,
Günter




[basex-talk] Ignore option for full-text-search

2016-01-03 Thread kleist
Hi Christian,

my long-time project (kleist-digital.de) is nearly only based on documents 
(TEI-xml), so I'm working mostly with mixed content. Are there any plans for 
future versions to implement the ignore option for full-text-search? It would 
help a lot.

Best,
Günter


[basex-talk] XQery Performance-Problem when using variables

2016-01-02 Thread kleist
Dear members, dear Christian,

when using a for-loop inside of a for-loop I run into serious 
performance-problems, when I'm using variables to return results.
For example this code-line takes 36780ms (!!!) for evaluation:

return  {$title}{$quote}

When I substitute the variable $time with the defining code, it takes only 
711ms for evaluation (!!):


{ if ($ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="short"]) then 
$ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="short"]/string()
else if 
($ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="article"]) then 
$ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="article"]/string()
else if ($ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="main"]) 
then $ele/ancestor::tei:TEI//tei:titleStmt/tei:title[@type="main"]/string()
else ()}
{$quote}

The only difference in the code is using a variable and it differs in 
performance by a factor of more than 50. In my real application (using more 
variables) it differs by factor more than 150.

I tried to simulate the problem with a simple factbook-query. Here is the code:
xquery version "3.0";
let $query := "Pa.*"
for $city in doc('factbook')//city/name
 for $hits in ft:mark($city[.//text() contains text {$query} using wildcards])
 let $country_of_city := $city/ancestor::country/name
 return
 (: fast version: Evaluating 12.54ms :)
 
{$hits}{$city/ancestor::country/name}

 (: slow version: Evaluating 35.78 :)
 (: {$hits}{$country_of_city} :)

Also here is a performance bottleneck (not as dramatically: factor 3). Is there 
any solution to the problem? Now I'm working in my code without variables in 
the result part of the xquery, but it makes realy ugly non maintainable code.

Any help would be appreciated.
- Günter


[basex-talk] Full-text search with ft:mark (linking back)

2015-12-30 Thread kleist
Dear members,
given for example: ft:mark(//p[.//text() contains text 'real']). This will 
yield some results.
Is there any way, to link back to the documents, where p was found? I know, it 
would work without ft:mark, but I need the -tag inside of the results, 
especially for fuzzy-search-results.

Any help would be appreciated.
- Günter