Re: [basex-talk] How to configure org.basex.path

2024-02-03 Thread Marc Coenegracht
Hi Pierre-Yves,

Just a well meant word of warning: if you don't isolate the sites on your
server, a compromised site can attack the other sites and maybe even
the server itself (by planting a backdoor for instance).

As an additional security measure, since you're using Apache, you might
want to consider ModSecurity (maybe you already did). ModSecurity easily
fends off 90-95% of attacks in the default config, even more if you spend
some time on it.


best,
Marc



On Tue, 30 Jan 2024, Pierre-Yves Jallud wrote:

> Hi Marc,
>
> well, containers is still obscure for me and I know APACHE... and all the
> chain between DNS and virtual host. Moreover, BaseX is enough designed to be
> configured as I need. Specifying the ports, a .basex (a data and webapp
> repository with DBPATH and WEBPATH) for each site and the BASEX_JM variable
> (BASEX_JM="-Dorg.basex.path=/basex/home/path") can do the job =) But maybe one
> day I will evoluate... if it's necessary 
>
> I still have a problem for stopping BaseX instances but that will be another
> message  (just after).
>
> Greetings
> Pierre-Yves
>
> Le 26/01/2024 à 12:21, Marc Coenegracht a écrit :
> > Hello Pierre-Yves and Maud,
> >
> > I'm also trying to figure out a multi-site setup with BaseX and I'm very
> > curious about your structure and config. Are you using containers with the
> > reversed proxy? Especially Podman might be a secure and easy to maintain
> > option (if setup correctly) for a multi-site scenario with multiple BaseX
> > instances.
> >
> > regards,
> > Marc
> >
> >
> > On Fri, 26 Jan 2024, Pierre-Yves Jallud wrote:
> >
> >> Hälløw Christian,
> >>
> >> many thanks for your answer! I finaly came to this solution yesterday
> >> afternoon and I was answering to my question when you send your answer. I
> >> first tried to use an relative directory... until I tried an absolute one
> >> and
> >> I succeeded to pass the java system property (something like export
> >> BASEX_JM="-Dorg.basex.path=/basex/home/path").
> >>
> >> To explain the context of our lab, we are using several instances of BaseX
> >> in
> >> the same machine (LINUX). To facilitate the administration (mainly the
> >> BaseX
> >> code update), we try to use a single BaseX repository for several sites.
> >> Each
> >> site has its own environment (data, webapp and .logs) and the basex
> >> repository
> >> is a symbolic link. We are using an APACHE HTTP server to access each BaseX
> >> with virtualhosts and proxypass configurations...
> >>
> >> And well, it seems to work now 朗! But if you have recommendations or other
> >> suggestions to facilitate system administration for a BaseX cluster, we are
> >> completly open =) Furthermore, we are not yet at the intensive production
> >> stage. If we encounter other problems, we'll ask for your help 
> >>
> >> Many thanks to you and all the BaseX team! You're making a great job!
> >>
> >> Greetings
> >> Pierre-Yves and Maud
> >>
> >> Le 25/01/2024 à 17:02, Christian Grün a écrit :
> >>> Salut Pierre-Yves,
> >>>
> >>> The home directory can be specified via the Java system property
> >>> “org.basex.path”. As it’s required before BaseX is even started, it must
> >>> be
> >>> passed on to the JDK, e.g. via “-Dorg.basex.path=/path/to/my/basex”. This
> >>> string can be…
> >>>
> >>> • statically added to the BASEX_JVM property in your “basexhttp” start
> >>> script, or
> >>> • dynamically assigned to JDK_JAVA_OPTIONS on command-line before running
> >>> “basexhttp” (export JDK_JAVA_OPTIONS=...).
> >>>
> >>> Hope this helps. If not, just keep on asking ;)
> >>>
> >>> Merci et salutations,
> >>> Christian
> >>>
> >>>
> >>> On Wed, Jan 24, 2024 at 5:09 PM Pierre-Yves Jallud
> >>>   wrote:
> >>>
> >>>  Hi all,
> >>>
> >>>  I would like to precise the home directory of BaseX using
> >>>  org.basex.path (cf.
> >>>  https://docs.basex.org/wiki/Configuration#Home_Directory). Is it
> >>>  possible to configure this when I launch the basexhttp? For
> >>>  exemple, something like (befor launching basexhttp):
> >>>
> >>>  export org.basex.path=/path/to/my/basex
> >>>
> >>>  Or maybe:

Re: [basex-talk] How to configure org.basex.path

2024-01-26 Thread Marc Coenegracht
Hello Pierre-Yves and Maud,

I'm also trying to figure out a multi-site setup with BaseX and I'm very
curious about your structure and config. Are you using containers with the
reversed proxy? Especially Podman might be a secure and easy to maintain
option (if setup correctly) for a multi-site scenario with multiple BaseX
instances.

regards,
Marc


On Fri, 26 Jan 2024, Pierre-Yves Jallud wrote:

> Hälløw Christian,
>
> many thanks for your answer! I finaly came to this solution yesterday
> afternoon and I was answering to my question when you send your answer. I
> first tried to use an relative directory... until I tried an absolute one and
> I succeeded to pass the java system property (something like export
> BASEX_JM="-Dorg.basex.path=/basex/home/path").
>
> To explain the context of our lab, we are using several instances of BaseX in
> the same machine (LINUX). To facilitate the administration (mainly the BaseX
> code update), we try to use a single BaseX repository for several sites. Each
> site has its own environment (data, webapp and .logs) and the basex repository
> is a symbolic link. We are using an APACHE HTTP server to access each BaseX
> with virtualhosts and proxypass configurations...
>
> And well, it seems to work now 朗! But if you have recommendations or other
> suggestions to facilitate system administration for a BaseX cluster, we are
> completly open =) Furthermore, we are not yet at the intensive production
> stage. If we encounter other problems, we'll ask for your help 
>
> Many thanks to you and all the BaseX team! You're making a great job!
>
> Greetings
> Pierre-Yves and Maud
>
> Le 25/01/2024 à 17:02, Christian Grün a écrit :
> > Salut Pierre-Yves,
> >
> > The home directory can be specified via the Java system property
> > “org.basex.path”. As it’s required before BaseX is even started, it must be
> > passed on to the JDK, e.g. via “-Dorg.basex.path=/path/to/my/basex”. This
> > string can be…
> >
> > • statically added to the BASEX_JVM property in your “basexhttp” start
> > script, or
> > • dynamically assigned to JDK_JAVA_OPTIONS on command-line before running
> > “basexhttp” (export JDK_JAVA_OPTIONS=...).
> >
> > Hope this helps. If not, just keep on asking ;)
> >
> > Merci et salutations,
> > Christian
> >
> >
> > On Wed, Jan 24, 2024 at 5:09 PM Pierre-Yves Jallud
> >  wrote:
> >
> > Hi all,
> >
> > I would like to precise the home directory of BaseX using
> > org.basex.path (cf.
> > https://docs.basex.org/wiki/Configuration#Home_Directory). Is it
> > possible to configure this when I launch the basexhttp? For
> > exemple, something like (befor launching basexhttp):
> >
> > export org.basex.path=/path/to/my/basex
> >
> > Or maybe:
> >
> > basexhttp -S org.basex.path=/path/to/my/basex
> >
> > ... or what else?
> >
> > Many thanks in advance to enlighten me 
> >
> > Pierre-Yves
> >
> > PS: as you can see, I didn't use Java for a long time 
> >
> > 
> > *Pierre-Yves Jallud*
> > /Pôle Humanité Numériques / Ingénieur en ingénierie logicielle/
> >
> > 
> > IHRIM - UMR 5317 <http://ihrim.ens-lyon.fr>
> > CNRS <https://www.cnrs.fr>
> > ENS de Lyon <http://www.ens-lyon.fr>
> > 15 Parvis René Descartes - BP7000 - 69342 Lyon CEDEX 07
> > +33 (0)4 37 37 63 83 - pierre-yves.jal...@ens-lyon.fr
> > 
> >
> 
> *Pierre-Yves Jallud*
> /Pôle Humanité Numériques / Ingénieur en ingénierie logicielle/
>
> 
> IHRIM - UMR 5317 <http://ihrim.ens-lyon.fr>
> CNRS <https://www.cnrs.fr>
> ENS de Lyon <http://www.ens-lyon.fr>
> 15 Parvis René Descartes - BP7000 - 69342 Lyon CEDEX 07
> +33 (0)4 37 37 63 83 - pierre-yves.jal...@ens-lyon.fr
> 
>

[basex-talk] RESTXQ Custom Multipart Response

2023-10-29 Thread Jean-Marc ANSEL

Hello,

I'm trying to do a custom multipart response with basex RESTXQ module.

The Custom Response paragraph of https://docs.basex.org/wiki/RESTXQ  
indicates :


Custom responses can be generated in XQuery by returning an 
|rest:response| element, an |http:response| child node that matches the 
syntax of the EXPath HTTP Client Module 
 specification, and optional child 
nodes that will be serialized as usual.


So, the §4.1 of http://expath.org/spec/http-client   (EXPath HTTP Client 
Module ) indicates :



   (http:header*,
 (http:multipart |
  http:body)?)



But when I try :

declare %rest:path('media4') function page:testjm4() {


      
          
            TEST
          
      
};


The answer is irremediably :

Stopped at /root/basex/webapp/test.xqm, 46/39:
[basex:restxq] Unexpected node: http://expath.org/ns/http-client; 
media-type="text">TEST 

Neither hhtp:body or http:multipart element can be placed as a child of 
http:response, that seems contradictory with the expath.org spec...


Any help would be appreciated...

Thanks o lot!

JM

Using :

BaseX Version 10.7
httpserver : basexhttp
Operating System: Ubuntu 18.04.6 LTS
Kernel: Linux 4.15.0-197-generic
Architecture: x86-64



Re: [basex-talk] Error messages in Basex 9.7.x

2022-08-14 Thread Marc Coenegracht
Thanks for the quick response Christian. I'll switch off
debugging then, excellent solution.

best,
Marc


On Sun, 14 Aug 2022, Christian Grün wrote:

> Hi Marc,
>
> Thanks for your feedback. If debugging is enabled, the returned error
> output can safely be ignored. The debugging mode is mostly helpful if
> errors occur repeatedly that need to be analyzed more closely.
>
> Cheers,
> Christian
>
>
>
> Marc Coenegracht  schrieb am So., 14. Aug. 2022, 20:41:
>
> > Hello Christian,
> >
> > In a clean install of Debian 11, openjdk version "11.0.16" 2022-07-19, I
> > unzipped BaseX973.zip and started the the HTTP server with: basexhttp -S
> > (with debugging set to true).
> >
> > The following error-message appeared:
> > java.lang.IllegalThreadStateException: process hasn't exited
> > at java.base/java.lang.ProcessImpl.exitValue(ProcessImpl.java:521)
> > at org.basex.util.Util.error(Util.java:311)
> > at org.basex.BaseXHTTP.start(BaseXHTTP.java:301)
> > at org.basex.BaseXHTTP.(BaseXHTTP.java:125)
> > at org.basex.BaseXHTTP.main(BaseXHTTP.java:54)
> >
> > which is repeated 10 times (all messages are exactly identical)
> >
> > If the server gets started with: 'basexhttp &' all is fine, no errors.
> > The server starts up normally after these errors and it can be shut down
> > cleanly again.
> >
> >
> > In a few of my scripts the following errors pops up:
> >
> > Creating Database...
> > java.lang.ClassNotFoundException:
> > com.sun.org.apache.xerces.internal.util.XMLCatalogResolver
> > at
> > java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
> > at ... etc (multiple classes, long list)
> >
> > Creating Database...
> > .java.lang.NumberFormatException: For input string: "E"
> > at
> > java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
> > at ... etc
> >
> > repeated twice.
> >
> > The errors are seemingly without consequence, all is functioning fine and
> > the created databases seem OK. Actually the only reason I noticed the
> > errors is because I made the foolish decision to set debugging to true ...
> > :)
> >
> > I tested versions 9.7 and 9.7.3 on multiple Debian 11 boxes with
> > openjdk 11.0.16, and version 9.7 in an older Debian 9 box with openjdk
> > 11.0.6, results are identical.
> >
> >
> > Best,
> > Marc
> >
>

[basex-talk] Error messages in Basex 9.7.x

2022-08-14 Thread Marc Coenegracht
Hello Christian,

In a clean install of Debian 11, openjdk version "11.0.16" 2022-07-19, I
unzipped BaseX973.zip and started the the HTTP server with: basexhttp -S
(with debugging set to true).

The following error-message appeared:
java.lang.IllegalThreadStateException: process hasn't exited
at java.base/java.lang.ProcessImpl.exitValue(ProcessImpl.java:521)
at org.basex.util.Util.error(Util.java:311)
at org.basex.BaseXHTTP.start(BaseXHTTP.java:301)
at org.basex.BaseXHTTP.(BaseXHTTP.java:125)
at org.basex.BaseXHTTP.main(BaseXHTTP.java:54)

which is repeated 10 times (all messages are exactly identical)

If the server gets started with: 'basexhttp &' all is fine, no errors.
The server starts up normally after these errors and it can be shut down 
cleanly again.


In a few of my scripts the following errors pops up:

Creating Database...
java.lang.ClassNotFoundException:
com.sun.org.apache.xerces.internal.util.XMLCatalogResolver
at 
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at ... etc (multiple classes, long list)

Creating Database...
.java.lang.NumberFormatException: For input string: "E"
at 
java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
at ... etc

repeated twice.

The errors are seemingly without consequence, all is functioning fine and
the created databases seem OK. Actually the only reason I noticed the
errors is because I made the foolish decision to set debugging to true ... :)

I tested versions 9.7 and 9.7.3 on multiple Debian 11 boxes with
openjdk 11.0.16, and version 9.7 in an older Debian 9 box with openjdk
11.0.6, results are identical.


Best,
Marc


Re: [basex-talk] xquery:eval and permissions [updated]

2022-08-08 Thread Marc Balston
Wow, that was quick!That gives me another reason to upgrade to BaseX 10!
Many thanksMarc M. Balston
M: +44 7786 263 906 

On Monday, 8 August 2022 at 16:15:16 BST, Christian Grün 
 wrote:  
 
 > I’ll have some more thought on that, as we currently don’t have any
> functions that have dynamic permissions at runtime.

And it was easier than expected. Feel free to check out the latest
stable snapshot [1].

Best,
Christian

[1] https://files.basex.org/releases/latest/
  

Re: [basex-talk] xquery:eval and permissions [updated]

2022-08-08 Thread Marc Balston
Hi Christian,
Although the string evaluated by xquery:eval will always be an XPath, that 
string is itself constructed within a rather complex query.  The query accepts 
several parameters which are each used to construct individual XPath 
expressions.  Originally the query was constructed so that each of these XPaths 
were evaluated immediately, by applying them to a common subset.  This subset 
would then successively narrow as each parameter was applied.  However, I 
realised that by constructing the complete XPath and applying it once through 
xquery:eval I could better leverage the optimisation of BaseX.  This approach 
improved performance dramatically.
It sounds like what I'm trying to do isn't possible currently, but I'd 
certainly appreciate it if it could be made possible in an update.  Many 
thanksMarc M. Balston
M: +44 7786 263 906 

On Monday, 8 August 2022 at 15:49:38 BST, Christian Grün 
 wrote:  
 
 Hi Marc,

The invocation of xquery:eval requires admin privilegues; but if you
are an admin user, you can decide under which permissions this query
will be executed.

If you want to evaluate an XPath expression with a limited user and
the REST API, it should be sufficient to supply this path as query:

  http://localhost/rest/db?query=/path

You can also address and run a server-side query:

  http://localhost/rest/db?run=xpath.xq

If you need to further process the results of a dynamic XPath query,
you’ll probably need to switch to RESTXQ.

Your use case is inspiring, though: Maybe we could make xquery:eval
more flexible and run it with the permissions of the current client. A
client may then be allowed to further restrict the permission scope:
If a client has 'read' permissions, (s)he could further restrict the
permissions to 'none' (but not extend it to e.g. 'write').

I’ll have some more thought on that, as we currently don’t have any
functions that have dynamic permissions at runtime.

Best,
Christian
  

Re: [basex-talk] Incompatibility with Tomcat 10

2022-04-05 Thread Marc Balston
Hi Christian,
Many thanks.  I hadn't tried that, but I'll definitely give it a go.  It does 
sound like it will be a simple fix. RegardsMarc M. Balston
M: +44 7786 263 906 

On Tuesday, 5 April 2022, 17:54:45 BST, Christian Grün 
 wrote:  
 
 Maybe you can resolve the issue by following the instructions given on
the homepage of Tomcat; did you try that?

“Applications that run on Tomcat 9 and earlier will not run on Tomcat
10 without changes. Java EE based applications designed for Tomcat 9
and earlier may be placed in the $CATALINA_BASE/webapps-javaee
directory and Tomcat will automatically convert them to Jakarta EE and
copy them to the webapps directory. This conversion is performed using
the Apache Tomcat migration tool for Jakarta EE tool which is also
available as a separate download for off-line use.” [1]

Best,
Christian

[1] https://tomcat.apache.org/



On Tue, Apr 5, 2022 at 6:47 PM Christian Grün  wrote:
>
> Hi Marc,
>
> Thanks for testing and the StackOverflow links.
>
> I think you’ve already discovered the weak spot, which is also
> documented in the Tomcat Migration Guide [1]: The javax.servlet
> packages are not available in Tomcat 10 anymore, so the import
> statements of BaseX would need to be updated.
>
> As BaseX comes with Jetty as standard web server, which relies on the
> javax.servlet package, the Open-Source version of BaseX will remain
> unchanged; but we can offer a custom Tomcat 10 version of BaseX for
> those who are using BaseX commercially.
>
> We’ll do some tests soon to confirm the assumption and update the
> documentation [2].
>
> Best,
> Christian
>
> [1] https://tomcat.apache.org/migration-10.html
> [2] https://github.com/BaseXdb/basex/issues/2085
>
>
> On Mon, Apr 4, 2022 at 2:34 PM Marc Balston  wrote:
> >
> > Hi Christian,
> >
> > I was using BaseX 9.5 on Tomcat 8.5 and it was fine.
> >
> > On Tomcat 10.0.2 I couldn't get either BaseX 9.5 or 9.7 to work (same 
> > issue).
> >
> > I now have Tomcat 9.0.62 running and I've successfully run both BaseX 9.5 
> > and 9.7.
> >
> > Regards
> > Marc
> >
> >
> > On Monday, 4 April 2022, 12:26:32 BST, Christian Grün 
> >  wrote:
> >
> >
> > Hi Marc,
> >
> > I remember there were problem with a past release of BaseX and Tomcat.
> > Which version of BaseX are you using?
> >
> > Best,
> > Christian
> >
> >
> >
> > On Sun, Apr 3, 2022 at 10:45 PM Marc Balston  wrote:
> > >
> > > Hello,
> > >
> > > I've been successfully running BaseX on Amazon AWS using Tomcat 8.5, but 
> > > I've been looking to upgrade my server to Tomcat 10.0.2.
> > > However, I've run into an issue: BaseX does not startup and from the logs 
> > > the cause appears to be a missing class:
> > >    java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionListener
> > >
> > > I believe this is because there was a change between Tomcat 9.x and 
> > > Tomcat 10 which led to a renaming of the javax.* package to jakata.* 
> > > (related to a change in the servlet API version) see here for a 
> > > discussion: 
> > > https://stackoverflow.com/questions/66711660/tomcat-10-x-throws-java-lang-noclassdeffounderror-on-javax-servlet
> > >
> > > Is my understanding correct and is this a known issue?
> > > If it is a genuine incompatibility, it would be useful to mention this in 
> > > the documentation (Web Application - BaseX Documentation)
> > >
> > > Thanks
> > > Marc
> > >
> > >
> > >
> > > Marc Balston
> > >
  

Re: [basex-talk] Incompatibility with Tomcat 10

2022-04-04 Thread Marc Balston
Hi Christian,
I was using BaseX 9.5 on Tomcat 8.5 and it was fine.
On Tomcat 10.0.2 I couldn't get either BaseX 9.5 or 9.7 to work (same issue).
I now have Tomcat 9.0.62 running and I've successfully run both BaseX 9.5 and 
9.7. 
RegardsMarc 
On Monday, 4 April 2022, 12:26:32 BST, Christian Grün 
 wrote:  
 
 Hi Marc,

I remember there were problem with a past release of BaseX and Tomcat.
Which version of BaseX are you using?

Best,
Christian



On Sun, Apr 3, 2022 at 10:45 PM Marc Balston  wrote:
>
> Hello,
>
> I've been successfully running BaseX on Amazon AWS using Tomcat 8.5, but I've 
> been looking to upgrade my server to Tomcat 10.0.2.
> However, I've run into an issue: BaseX does not startup and from the logs the 
> cause appears to be a missing class:
>    java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionListener
>
> I believe this is because there was a change between Tomcat 9.x and Tomcat 10 
> which led to a renaming of the javax.* package to jakata.* (related to a 
> change in the servlet API version) see here for a discussion: 
> https://stackoverflow.com/questions/66711660/tomcat-10-x-throws-java-lang-noclassdeffounderror-on-javax-servlet
>
> Is my understanding correct and is this a known issue?
> If it is a genuine incompatibility, it would be useful to mention this in the 
> documentation (Web Application - BaseX Documentation)
>
> Thanks
> Marc
>
>
>
> Marc Balston
>
  

Re: [basex-talk] GUI syntax highlighting

2022-03-23 Thread Marc Coenegracht
Thank you Christian, from a happy night coder.

Best,
Marc



On Wed, 23 Mar 2022, Christian Grün wrote:

> Fixed [1]; thanks for the observation.
> All the best, Christian
>
> [1] https://files.basex.org/releases/latest/
>
>
>
> > The syntax highlighting doesn't change when changing the look and feel in
> > the BaseX GUI (9.6.2). I noticed this also happens in earlier versions.
> > After changing to a dark background this results in blue on black, for
> > instance. This happens with the JTattoo lib, but also GTK under a dark
> > Linux theme.
> >
> > This occurs in Linux, all kinds of distro's, both Debian and Fedora
> > based. Open JDK 11.0.6.
> >
> > In BaseX GUI 8.6.x all is fine, running under the same conditions.
> >
> >
> > Regards,
> > Marc
> >
>

[basex-talk] GUI syntax highlighting

2022-03-22 Thread marc
The syntax highlighting doesn't change when changing the look and feel in
the BaseX GUI (9.6.2). I noticed this also happens in earlier versions.
After changing to a dark background this results in blue on black, for
instance. This happens with the JTattoo lib, but also GTK under a dark
Linux theme.

This occurs in Linux, all kinds of distro's, both Debian and Fedora
based. Open JDK 11.0.6.

In BaseX GUI 8.6.x all is fine, running under the same conditions.


Regards,
Marc



[basex-talk] Log4j vulnerability CVE-2021-44228

2021-12-13 Thread Marc Coenegracht
Does Basex (9.x or 8.x) use Log4j in any of its components?
If not, should one still worry about the JRE?


Regards,
Marc


Re: [basex-talk] Coding help

2019-08-08 Thread Marc

For this type of project, I regard into the solution with a file:list and a 
stream use of XSLT, or a use of the saxon:discard-document or the use of 
collection as in 
https://ajwelch.blogspot.com/2006/11/using-collection-and-saxondiscard.html

If the query to select file doesn'y need Xquery but XPath, it can be done like 
that. If the collection is to big you can do more than one pass with the file 
selector (files started by a, next b, etc)

Marc

Le 06/08/2019 à 18:12, Majewski, Steven Dennis (sdm7g) a écrit :


Creating a bunch of temporary databases that you’re going to delete
doesn’t sound like the most efficient way to process this data.
But it hard to tell what alternative to recommend without more info
about what your desired end result is.

Is this something that you’re going to do once, or do repeatedly for
different strings ?

Taking your description literally, I would use ‘grep -l ‘ to generate a
list of files with the specific string, and either feed that list into
‘cat’ or else use it to build a database of a subset of files for
further investigation.

There are also other ways to filter the data through a stream to select
a subset if that is what you want to do.

But if you’re going to do this repeatedly for different subsets, then it
might make more sense to try to get everything parsed and indexed into
the database once. If it really is too large for a single database after
adjusting the java memory parameters in the basex scripts, you could try
sharding the data into several databases, repeat the search on each
collection, and concatenate the results.




> On Aug 5, 2019, at 2:41 AM, Greg Kawchuk  <mailto:greg.kawc...@ualberta.ca>> wrote:
>
> Hi everyone,
> I'm wondering if someone could provide what I think is a brief script
> for a scientific project to do the following.
> The goal is to identify XML documents from a very large collection
> that would be too big to load into a database all at once.
>
> Here is how I see the functions provided by the code.
> 1. In the script, the user could enter the path of the target folder
> (with millions of XML documents).
> 2. In the script, the user would enter the number of documents to load
> into a database at a given time (i =. 1,000) depending on memory
> limitations.
> 3. The code would then create a temporary database from the first (i)
> xml files in the target folder.
> 4. The code would then search the 1000 xml documents in the database
> for a pre-defined text string.
> 5. If hits exist for the text string, the code would write those
> documents to a unique XML file.
> 6. Clear the database.
> 7. Read in the next 1000 files (or remaining files in the folder).
> 8. Return to #4.
>
> There would be no need to append XML files in step 5. The resulting
> XML files could be concatenated afterwards.
> Thank you in advance. If you have any questions, please feel free to
> email me here.
> Greg
>
> ***
> Greg Kawchuk BSC, DC, MSc, PhD.
> Professor, Faculty of Rehabilitation Medicine
> University of Alberta
> greg.kawc...@ualberta.ca <mailto:greg.kawc...@ualberta.ca>
> 780-492-6891





Re: [basex-talk] comment()

2019-08-08 Thread Marc

Thanks you very much.
I use very often the comment() with XSLT, and I confuse it with the 
"comment" literal of XQuery !

Marc


Le 07/08/2019 à 19:22, Majewski, Steven Dennis (sdm7g) a écrit :



Also literal  work just like other literal XML, as there is 
a different syntax for (: XQuery comments  :)

XQuery: { collection()[1]//comment() }  { comment { 
" last comment " } }  (: XQuery Comment :)

Produced output:


   
   
   
   
   
   



"comment()"   is the XPath syntax to match a comment node, not a function that 
creates comments.

— Steve M.




On Aug 7, 2019, at 1:03 PM, Martin Honnen  wrote:

On 07.08.2019 18:52, Marc wrote:


I want to write a comment in the xml I produce with my XQuery.
I try to use the comment() function, but each time I want to put
something inside the () i have a syntax error.


If you want to create a comment node computed by an expression use
  comment { expression }

see https://www.w3.org/TR/xquery-31/#doc-xquery31-CompCommentConstructor

So
  comment { $r }
seems to be what you want to do.




[basex-talk] comment()

2019-08-07 Thread Marc

Hi,
I want to write a comment in the xml I produce with my XQuery.
I try to use the comment() function, but each time I want to put 
something inside the () i have a syntax error.


for example :

{comment("test"),
  let $r := random:integer(100) + 1
for $j in (/*)[$r]
return (
  $r,$j)
}


or (who is more what I want to do)


{
  let $r := random:integer(100) + 1
for $j in (/*)[$r]
return (comment("$r"),$j)
}


I don't find any example on how to use the comment function.
Anyone have example about that use?

Thanks

Marc


[basex-talk] Transaction management in BaseX 8.6.4

2018-08-08 Thread Marc Coenegracht

Hi,

A CMS occasionally recreates some existing databases of a production site. 
The databases are deleted and again created with the new content within 
a few seconds.


What happens if a read operation is taking place during this process? Can 
it cause problems with the recreation of the DB or with the BaseX server 
instance?


Of course it is possible to update the databases instead, but this process 
is a lot simpler and probably faster too.


All operations are executed running xquery scripts with REST using the 
BaseX http server.



Marc


Re: [basex-talk] Maven repo 9.0

2018-03-27 Thread Marc van Grootel
Hi Dirk,

Yes, it is synced to Maven Central now.
The net.xqj:basex-xqj:9.0 dependency still requires adding the
http://files.basex.org/maven repo though as it cannot be found on MC.

Thanks,
--Marc

On Tue, Mar 27, 2018 at 5:12 PM, Kirsten, Dirk <dirk.kirs...@senacor.com> wrote:
> Hi Marc, hi list,
>
> unfortunately something went wrong during Christians deploy process and he
> is now on (a well-deserved) holiday. However, he wrote me about it (as I
> setup the Maven Central deploy process and I think I just "fixed" it (not
> really a fix, but using the UI...). It is release to OSSHR and should be
> synced to Maven Central (https://mvnrepository.com/artifact/org.basex) in a
> short while.
> Note, that it is not release to the own BaseX Maven Repository - I am not
> sure whether Christian did this on purpose (because havin the files in Maven
> Central should be enough for anyone I guess) or just missed it.
>
> Cheers
> Dirk
>
>
> Senacor Technologies Aktiengesellschaft - Sitz: Eschborn - Amtsgericht
> Frankfurt am Main - Reg.-Nr.: HRB 105546
> Vorstand: Matthias Tomann, Marcus Purzer - Aufsichtsratsvorsitzender: Daniel
> Grözinger
>
> -Ursprüngliche Nachricht-
> Von: basex-talk-boun...@mailman.uni-konstanz.de
> [mailto:basex-talk-boun...@mailman.uni-konstanz.de] Im Auftrag von Marc van
> Grootel
> Gesendet: Dienstag, 27. März 2018 15:49
> An: BaseX <basex-talk@mailman.uni-konstanz.de>
> Betreff: [basex-talk] Maven repo 9.0
>
>
> Hi,
>
> First of all congrats with the release of the Spring edition. Nice steady
> pace of quality updates.
>
> I wanted to test 9.0 by getting it via de Maven coordinates but noticed that
> 9.0 wasn't available from the basex Maven repo. Only 9.0-SNAPSHOT and
> 9.0.1-SNAPSHOT.
>
> Is it possible to also make 9.0 available from org.basex:basex-api:9.0 Maven
> coordinates?
>
> --Marc



-- 
--Marc


[basex-talk] Maven repo 9.0

2018-03-27 Thread Marc van Grootel
Hi,

First of all congrats with the release of the Spring edition. Nice
steady pace of quality updates.

I wanted to test 9.0 by getting it via de Maven coordinates but
noticed that 9.0 wasn't available from the basex Maven repo. Only
9.0-SNAPSHOT and 9.0.1-SNAPSHOT.

Is it possible to also make 9.0 available from org.basex:basex-api:9.0
Maven coordinates?

--Marc


Re: [basex-talk] proc:system ?

2017-10-13 Thread jean-marc Mercier
Andy,

Thank you for your answer. Indeed, the length of my parameters are now much
more than the Windows limit.
I guess that creating a temporary file, then passing the name of the file
as parameters should solve the issue.
Cheers,
Jean-Marc

2017-10-13 10:42 GMT+02:00 Andy Bunce <bunce.a...@gmail.com>:

> Hi Jean-Marc,
>
> I have hit this kind of issue before and it is not BaseX specific. The
> problem is Windows(tm) limits [1]
> This is compounded by the Java call from proc:system passing in a copy of
> the environment of the current process [2].
> Mine has built up a large class path over time with my lib/custom
> experiements. My  `proc:property("java.class.path")` is nearly 4k
>
> You could try to "clean" your classpath and switch your file locations to
> shorter paths
>
> /Andy
>
> [1] https://support.microsoft.com/en-gb/help/830473/command-prom
> pt-cmd--exe-command-line-string-limitation
> [2] https://docs.oracle.com/javase/7/docs/api/java/lang/ProcessB
> uilder.html#environment()
>
> On 12 October 2017 at 11:19, jean-marc Mercier <jeanmarc.merc...@gmail.com
> > wrote:
>
>> Hello BaseX team,
>>
>> I am an extensive user of the proc:system BaseX command (and looking
>> forward for proc:fork !).
>>  I am using this command with in-memory arguments, it means that my way
>> of using it is :
>> proc:system("my_exe", $my_arguments_for_exe)
>>
>> $my_arguments_for_exe is an xml node serialized to string by BaseX. As my
>> test are getting more complex, the size of $my_arguments_for_exe are
>> increasing. It seems that we are reaching a limit now, since the compiler
>> refuses to pass arguments :
>>
>> "Stopped at CoDeFi_Interface.xqm, 44/22:
>> [BXPR] Cannot run program 
>> "C:\Jiheme\scientifique\recherche\CoDeFi\CoDeFi\CoDeFi.exe":
>> CreateProcess error=206, Nom de fichier ou extension trop long
>> "
>> Is there a way to bypass this ?
>>
>> Thank you for your answer,
>>
>> Cheers,
>>
>> Jean-Marc
>>
>
>


[basex-talk] proc:system ?

2017-10-12 Thread jean-marc Mercier
Hello BaseX team,

I am an extensive user of the proc:system BaseX command (and looking
forward for proc:fork !).
 I am using this command with in-memory arguments, it means that my way of
using it is :
proc:system("my_exe", $my_arguments_for_exe)

$my_arguments_for_exe is an xml node serialized to string by BaseX. As my
test are getting more complex, the size of $my_arguments_for_exe are
increasing. It seems that we are reaching a limit now, since the compiler
refuses to pass arguments :

"Stopped at CoDeFi_Interface.xqm, 44/22:
[BXPR] Cannot run program
"C:\Jiheme\scientifique\recherche\CoDeFi\CoDeFi\CoDeFi.exe": CreateProcess
error=206, Nom de fichier ou extension trop long
"
Is there a way to bypass this ?

Thank you for your answer,

Cheers,

Jean-Marc


Re: [basex-talk] Strange compilator behavior ?

2017-10-09 Thread jean-marc Mercier
Christian,

Yes absolutely. Thx for your answer.
Cheers,

Jean-Marc

2017-10-09 18:00 GMT+02:00 Christian Grün <christian.gr...@gmail.com>:

> > Yes. But my question is : why did the BaseX compiler ran the query let
> $idd
> > := $elt[d]/@id ?
>
> The query is valid, because $elt could have an element named d. For
> example, the following query returns the value of $elt:
>
>   let $elt := 
>   return $elt[d]
>
> Does this help?
> Christian
>
>
>
> > Shouldn't it raise a compilation error ?
> >
> >
> >
> > 2017-10-09 17:49 GMT+02:00 Christian Grün <christian.gr...@gmail.com>:
> >>
> >> Dear Jean-Marc,
> >>
> >> > let $idd := $elt[d]/@id
> >>
> >> Shouldn’t it be '$d' instead of 'd' ?
> >>
> >>   let $idd := $elt[$d]/@id
> >>
> >> Cheers,
> >> Christian
> >>
> >>
> >>
> >> > return ($elt[$d]/@id,$idd)
> >> >
> >> > output : id="yolo".
> >> >
> >> > (Hence missing the second "yolo", because the correct query is : let
> >> > $idd :=
> >> > $elt[$d]/@id)
> >> >
> >> > However I can't figure out why the BaseX compiler ran this query ?
> >> > Shouldn't
> >> > it refused the compilation and point out this error ?
> >> >
> >> > Cheers,
> >> >
> >> > Jean-Marc
> >> >
> >> >
> >> >
> >
> >
>


Re: [basex-talk] Strange compilator behavior ?

2017-10-09 Thread jean-marc Mercier
Hello Christian,

Yes. But my question is : why did the BaseX compiler ran the query let $idd
:= $elt[d]/@id ?
Shouldn't it raise a compilation error ?



2017-10-09 17:49 GMT+02:00 Christian Grün <christian.gr...@gmail.com>:

> Dear Jean-Marc,
>
> > let $idd := $elt[d]/@id
>
> Shouldn’t it be '$d' instead of 'd' ?
>
>   let $idd := $elt[$d]/@id
>
> Cheers,
> Christian
>
>
>
> > return ($elt[$d]/@id,$idd)
> >
> > output : id="yolo".
> >
> > (Hence missing the second "yolo", because the correct query is : let
> $idd :=
> > $elt[$d]/@id)
> >
> > However I can't figure out why the BaseX compiler ran this query ?
> Shouldn't
> > it refused the compilation and point out this error ?
> >
> > Cheers,
> >
> > Jean-Marc
> >
> >
> >
>


[basex-talk] Strange compilator behavior ?

2017-10-09 Thread jean-marc Mercier
Hello BaseX team !

I lost some time to detect an error in my code, and wonder if there is a
minor bug into the BaseX compiler. Here is the test

let $elt as element(*)*:= 
 for $d in (1 to 1)
 return
let $idd := $elt[d]/@id
return ($elt[$d]/@id,$idd)

output : id="yolo".

(Hence missing the second "yolo", because the correct query is : let $idd
:= $elt[$d]/@id)

However I can't figure out why the BaseX compiler ran this query ?
Shouldn't it refused the compilation and point out this error ?

Cheers,

Jean-Marc


Re: [basex-talk] map behavior ?

2017-09-26 Thread jean-marc Mercier
Hello Christian !

Nice to read you again ! I am striking back to BaseX, using it as my main
database server for a integrating / pricing / unittesting engine.
Ok, fair enough, I implement a sort_map function.



2017-09-26 12:01 GMT+02:00 Christian Grün <christian.gr...@gmail.com>:

> Dear Jean-Marc,
>
> Welcome back!
>
> Maps in XQuery are simple key/value pairs; neither keys nor values
> will be arranged in a specific order.
>
> If you want to sort map by keys before outputting them, you can sort
> them in a second step:
>
>   let $map := map:merge((
> map:entry(0.1, "Sunday"),
> map:entry(5.0, "Thursday"),
> map:entry(2.0, "Monday"),
> map:entry(3.0, "Wednesday"),
> map:entry(0.5, "Tuesday"),
> map:entry(6.0, "Friday"),
> map:entry(7.0, "Saturday")
>   ))
>   for $key in sort(map:keys($map))
>   return "* " || $key || ": " || $map($key)
>
> Hope this helps,
> Christian
>
>
>
>
> On Tue, Sep 26, 2017 at 11:29 AM, jean-marc Mercier
> <jeanmarc.merc...@gmail.com> wrote:
> > Hello BaseX team,
> >
> > It has been a while since I last wrote to this mailing list ! Happy to
> > report again :)
> >
> > I have a strange behavior concerning map, it doesn't seem to sort as I
> > expected. Is there any explanation ?
> >
> > let $map as map(xs:double,xs:string) := map:merge((
> >   map:entry(xs:double(0.1), "Sunday"),
> >   map:entry(xs:double(5.0), "Thursday"),
> >   map:entry(xs:double(2.0), "Monday"),
> >   map:entry(xs:double(3.0), "Wednesday"),
> >   map:entry(xs:double(0.5), "Tuesday"),
> >   map:entry(xs:double(6.0), "Friday"),
> >   map:entry(xs:double(7.0), "Saturday")
> > ))
> > return $map
> >
> > output :
> > map {
> >   2: "Monday",
> >   3: "Wednesday",
> >   5: "Thursday",
> >   6: "Friday",
> >   7: "Saturday",
> >   0.1: "Sunday",
> >   0.5: "Tuesday"
> > }
> >
> > Cheers
>


[basex-talk] map behavior ?

2017-09-26 Thread jean-marc Mercier
Hello BaseX team,

It has been a while since I last wrote to this mailing list ! Happy to
report again :)

I have a strange behavior concerning map, it doesn't seem to sort as I
expected. Is there any explanation ?

let $map as map(xs:double,xs:string) := map:merge((
  map:entry(xs:double(0.1), "Sunday"),
  map:entry(xs:double(5.0), "Thursday"),
  map:entry(xs:double(2.0), "Monday"),
  map:entry(xs:double(3.0), "Wednesday"),
  map:entry(xs:double(0.5), "Tuesday"),
  map:entry(xs:double(6.0), "Friday"),
  map:entry(xs:double(7.0), "Saturday")
))
return $map

output :
map {
  2: "Monday",
  3: "Wednesday",
  5: "Thursday",
  6: "Friday",
  7: "Saturday",
  0.1: "Sunday",
  0.5: "Tuesday"
}

Cheers


Re: [basex-talk] Validate XML against RNG schema

2017-06-21 Thread Marc van Grootel
No problem. Just use the validate:rng#3. Provide true() as the third
param and it should happily process compact syntax for you.
Getting includes to work is a different matter though so your schema
should probably be standalone. Otherwise, maybe, store the schemas on
the filesystem.

Cheers,
--Marc

On Wed, Jun 21, 2017 at 9:36 AM, Imsieke, Gerrit, le-tex
<gerrit.imsi...@le-tex.de> wrote:
> Hi Dharmendra,
>
> The function validate:rng() seems to only accept a Relax NG *XML syntax*
> document as its 2nd argument. You can convert the rnc file to rng using
> trang and store it in the DB as a regular XML file.
>
> Gerrit
>
> On 6/21/17 8:20 AM, Dharmendra Singh wrote:
>>
>> Hi all,
>>
>> I have loaded the RNG schema using function db:store and also loaded the
>> XML in the DB which has to be validated, but i am getting the error, below
>> is my code:
>>
>>
>>   let $binary := db:retrieve('onix','/relaxng/publishers-51cr.rnc')
>>let $schema := bin:decode-string($binary)
>>return
>>let $input := db:open('onix')
>>return validate:rng($input, $schema)
>>
>> when i run this code i get the error invalid XML charcter(20)
>>
>> so what i am doing wrong here.
>
>
> --
> Gerrit Imsieke
> Geschäftsführer / Managing Director
> le-tex publishing services GmbH
> Weissenfelser Str. 84, 04229 Leipzig, Germany
> Phone +49 341 355356 110, Fax +49 341 355356 510
> gerrit.imsi...@le-tex.de, http://www.le-tex.de
>
> Registergericht / Commercial Register: Amtsgericht Leipzig
> Registernummer / Registration Number: HRB 24930
>
> Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
> Thomas Schmidt, Dr. Reinhard Vöckler



-- 
--Marc


Re: [basex-talk] Create Options are deleted from .basex config file

2017-06-05 Thread Marc Coenegracht

Apparently that was the mistake.
Thank you!

Marc


On Mon, 5 Jun 2017, Christian Grün wrote:


Did you differentiate between global and local options [1]?

Cheers,
Christian

[1] http://docs.basex.org/wiki/Options


Am 05.06.2017 5:39 nachm. schrieb <m...@crosseyed.nl>:
  Options manually added to the .basex config file are deleted by BaseX.

  For example, these Create Options all get deleted from the .basex file
  after running a standalone basex script:

  ADDARCHIVES = true
  CREATEFILTER = *.anx
  STRIPNS = true
  INTPARSE = true
  LANGUAGE = Dutch (also tried 'nl')


  Basex 8.5.3 on Linux


  Regards,
  Marc





[basex-talk] Create Options are deleted from .basex config file

2017-06-05 Thread marc

Options manually added to the .basex config file are deleted by BaseX.

For example, these Create Options all get deleted from the .basex file 
after running a standalone basex script:


ADDARCHIVES = true
CREATEFILTER = *.anx
STRIPNS = true
INTPARSE = true
LANGUAGE = Dutch (also tried 'nl')


Basex 8.5.3 on Linux


Regards,
Marc


Re: [basex-talk] Exit a for-loop?

2017-02-27 Thread Marc van Grootel
Hi Joseph, 

Maybe hof:until [1] and hof:take-while [2]?

[1] http://docs.basex.org/wiki/Higher-Order_Functions_Module#hof:until
[2] http://docs.basex.org/wiki/Higher-Order_Functions_Module#hof:take-while


--Marc

> On 27 feb. 2017, at 19:25, Dirk Kirsten <d...@basex.org> wrote:
> 
> Hello Joseph,
> 
> to be honest, this doesn't sound particularly like functional
> programming. The nice thing about functional programming is that you
> shouldn't care about such optimization stuff (like breaking out of a for
> loop), but instead our optimizer should be clever enough to stop
> executing the function once he has enough results. So simply request the
> first result and you should be fine. Something like this:
> 
> 
>  (for $a at $pos in $seq1
>  where $a = $seq2[$pos]
>  return $a)[1]
> 
> Cheers
> 
> Dirk
> 
> 
>> On 02/27/2017 09:42 PM, Joseph wrote:
>> Hi,
>> 
>> I have two sets of numbers, and I would like to write a for-loop for
>> comparison, so that I get only the first match between the numbers. I
>> was thinking of a double for-loop, but I do not know how to exit the
>> comparison as soon as I get the first match. Any idea? Thanks.
>> 
>> 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 91 68 276, Fax: 0049 7531 20 05 22
> 


Re: [basex-talk] Somewhat unusual question

2017-02-25 Thread Marc van Grootel
reparing UI 
and content for translation, processing the translated content and merging it 
back into the application.

So, to sum it up. XML-based technologies, XQuery included, is proving it's 
value for us each and every day and using it succesfully also helps pave the 
way for increased usage in our company especially when dealing with publishing 
and data processing. Most often you will see them appear in between systems (as 
glue) or at the edges of a system (to deal with special requirements) as these 
parts often require more flexibility. 

I'm always trying to be open to alternative technologies for implementation and 
often I challenge others by asking for alternative solutions when I pitch the 
idea of using XML technology. I like to think that I have enough general 
knowledge of other languages to be able to advocate XML-tech when I think it is 
a better fit for the job. And I also think that we stay critical once a 
solution is chosen.

I do admit, however, that it is often more easy to hire a new Java developer 
than it is to hire an XML developer. In our company both exist side-by-side in 
the same team, and sometimes even in the same person.

In fact, I wrote this long response not only as an answer to this thread but 
also to let you know that we could use a new team member. Especially one that 
knows XML technologies well. In particular XSL-FO, XSLT and XQuery. But if you 
also have experience in either Java development or front-end Javascript 
development that would be even better. We, the IT team, operate from Eindhoven 
in the Netherlands but we have our headquarters in Manchester in the UK. If 
your are interested in knowing more about this opportunity then reply to me in 
private.
 
 --Marc



Re: [basex-talk] fn:doc weirdness with imported files

2017-01-11 Thread Marc van Grootel
Hi Christian,

Couldn't repro it with a command script, it got the expected behaviour
each way I tried. However, I can repro it consistently in the GUI.

GUI:

1. Create a new database
2. Point Input file or directory to an existing XML file, say,
"F:/tmp/foo.xml" (haven't verified behaviour on Mac yet)
3. Provide the db name, say, "foo"
4. Click OK
5. Execute following query in GUI: "base-uri(doc('F:/tmp/foo.xml'))"
(returns /foo/foo.xml as the database is now opened)
6. Close the database
7. Execute the same query. It now returns file:///F:/tmp/foo.xml

This was on 8.5.3 and 8.4.2 (btw on 8.4.2 step 4 returned
"foo/foo.xml" (without leading slash).

Thanks for the info on "database" nodes as, indeed, the description in
the docs threw me off a little.

Cheers,
--Marc


On Tue, Jan 10, 2017 at 5:45 PM, Christian Grün
<christian.gr...@gmail.com> wrote:
> Hi Marc,
>
>> When I have the database closed in the GUI
>>
>> base-uri(doc('F:/tmp/foo.xml')) => file:///F:/tmp/foo.xml
>>
>> And when I open the database "foo" from the GUI
>>
>> base-uri(doc('F:/tmp/foo.xml')) => /foo/foo.xml
>>
>> Is that right?
>
> I wouldn’t say so ;) As somewhat usual, I couldn’t reproduce it that
> easily. Could you possibly give me a step-by-step description how to
> proceed? Or ideally a command script that shows the behavior?
>
>>  db:node-id($node)
>>
>> should raise an error in case $node is not a database node.
>
> We should possibly switch to another naming, because "database node"
> is not that appropriate (anymore). The background: We have two
> different XML node representations in BaseX. One is object-oriented,
> and it’s the format used for node constructors:
>
>   db:node-id() → error
>   db:node-id(element x { }) → error
>
> It’s the most efficient solution for small XML fragments.
>
> "Database nodes" are based on a compact representation, which we use
> for serializing databases to disk. It is also applied to keep larger
> fragments in main-memory, so it is used e.g. when calling functions
> like doc(), or the 'update' keyword:
>
>   db:node-id(doc('bla.xml')) → 0
>   db:node-id( update {}) → 0
>
> Hope this helps,
> Christian



-- 
--Marc


Re: [basex-talk] fn:doc weirdness with imported files

2017-01-10 Thread Marc van Grootel
... am I missing something?

So this

  db:node-id($node)

should raise an error in case $node is not a database node. However in
the GUI and in the command-line client.

  db:node-id(doc('F:/tmp/afile.xml')) => 0
  db:node-id(doc('F:/tmp/afile.xml')/*) => 1

only requirement is that 'F:/tmp/afile.xml' exists as a file. Even
with no database open or existing and never having imported this file.

It doesn't depend on the format of the path and same result with
'F:\tmp\afile.xml', 'file:///F:/tmp/afile.xml'.

--Marc


On Tue, Jan 10, 2017 at 3:17 PM, Marc van Grootel
<marc.van.groo...@gmail.com> wrote:
> Hi all,
>
> Happy new year btw!
>
> I got bitten by something and can't explain this behaviour.
>
> So the situation is that I have an XML file on the file system in 
> F:/tmp/foo.xml
>
> I also have this file imported into a database named "foo" (and the
> path "/foo.xml".
>
> Now in the GUI (and on 8.5.3) I have the following.
>
> When I have the database closed in the GUI
>
> base-uri(doc('F:/tmp/foo.xml')) => file:///F:/tmp/foo.xml
>
> And when I open the database "foo" from the GUI
>
> base-uri(doc('F:/tmp/foo.xml')) => /foo/foo.xml
>
> Is that right? Also db:* functions also get a database node from the
> latter and return a node-id for example.
>
> When the foo.xml is moved to another filesystem directory then this
> doesn't happen so it appears as if this happens only when I try to
> read the file from the original import location.
>
> Shouldn't these two situations have the same result?
>
> Cheers,
> --Marc



-- 
--Marc


[basex-talk] fn:doc weirdness with imported files

2017-01-10 Thread Marc van Grootel
Hi all,

Happy new year btw!

I got bitten by something and can't explain this behaviour.

So the situation is that I have an XML file on the file system in F:/tmp/foo.xml

I also have this file imported into a database named "foo" (and the
path "/foo.xml".

Now in the GUI (and on 8.5.3) I have the following.

When I have the database closed in the GUI

base-uri(doc('F:/tmp/foo.xml')) => file:///F:/tmp/foo.xml

And when I open the database "foo" from the GUI

base-uri(doc('F:/tmp/foo.xml')) => /foo/foo.xml

Is that right? Also db:* functions also get a database node from the
latter and return a node-id for example.

When the foo.xml is moved to another filesystem directory then this
doesn't happen so it appears as if this happens only when I try to
read the file from the original import location.

Shouldn't these two situations have the same result?

Cheers,
--Marc


Re: [basex-talk] How to save Table views as spreadsheet

2016-12-21 Thread Marc van Grootel
Hi Constantine,

Instead of with POI do it with standard XQuery and XSLT. Here's the
gist (pun intended) of it
https://gist.github.com/xokomola/59a590a423b86bb3ea809c1b03706c4b
Haven't checked it for correctness but gives you an idea how it works.

--Marc

On Wed, Dec 14, 2016 at 9:15 AM, Hondros, Constantine (ELS-AMS)
<c.hond...@elsevier.com> wrote:
> Hi there,
>
> Unless I'm mistaken, I think the easiest thing to do is to serialise as CSV 
> and import into something like Excel.
>
> The CSV module can help you here: http://docs.basex.org/wiki/CSV_Module
>
> Although thinking about it, perhaps other folks have tried wrapping a library 
> like Apache POI (https://poi.apache.org/) so that spreadsheets can be created 
> directly from XQuery?
>
> Constantine
>
> -Original Message-
> From: basex-talk-boun...@mailman.uni-konstanz.de 
> [mailto:basex-talk-boun...@mailman.uni-konstanz.de] On Behalf Of 
> kalameg...@gmail.com
> Sent: 14 December 2016 00:10
> To: basex-talk@mailman.uni-konstanz.de
> Subject: [basex-talk] How to save Table views as spreadsheet
>
> I am new to BaseX which I find as a powerful tool to work on xml data. The 
> BaseX GUI  is great. My question is:  how can I save the Tables in the 
> visualization as spreadsheet(s).  I understand there are multiple views but 
> it should be possible to save them as separate tables or tabs in a single 
> spreadsheet.
>
> I apologize if this has been addresses in an earlier talk.
> I would like to know if there is a way to quickly search the base-talk 
> archives without having to look through them all (arranged by month).
>
> Thanks!   -R. Kalamegham
>
> 
>
> Elsevier B.V. Registered Office: Radarweg 29, 1043 NX Amsterdam, The 
> Netherlands, Registration No. 33156677, Registered in The Netherlands.



-- 
--Marc


Re: [basex-talk] map:merge new semantics for 8.6

2016-10-31 Thread Marc van Grootel
Thanks Christian,
I feared as much ;-(
I understand the reasoning (processing efficiency and compatibility
with parse-json) but find it unfortunate that backwards compatibility
wasn't part of the reasoning as maps and map:merge are not exactly
new.

--Marc

On Mon, Oct 31, 2016 at 1:50 PM, Christian Grün
<christian.gr...@gmail.com> wrote:
> Hi Marc,
>
> The reason is why this was decided by the W3C; see [1] and related comments.
>
> Sorry for that,
> Christian
>
> [1] https://www.w3.org/Bugs/Public/show_bug.cgi?id=29723
>
>
>
> On Mon, Oct 31, 2016 at 1:43 PM, Marc van Grootel
> <marc.van.groo...@gmail.com> wrote:
>> Hi,
>>
>> Any reason why the deault semantics for map:merge in 8.6 changed in a
>> backwards incompatible manner? Is this because of some XQuery/XPath
>> spec thing? A while ago I switched to 8.6-SNAPSHOT just to be on the
>> latest and greatest and I starting seeing weird things in my code.
>> Initially I didn't bother to look at the docs as I didn't expect
>> map:merge to have changed. At some point I even thought map:merge was
>> broken in this snapshot. I often use map:merge for handling function
>> options and I add the defaults first and then user options. With 8.6
>> this default behaviour has changed and I would have to switch this
>> around or explicitly ask for 'use-last'. I can do but only by adding
>> map { 'duplicates': 'use-last' }. This means I will have code <= 8.5
>> and I need to have different code for > 8.5.
>> Was this intentional? If not then I would vote for re-instating
>> default behaviour (use-last).
>>
>> Cheers,
>> --Marc



-- 
--Marc


[basex-talk] map:merge new semantics for 8.6

2016-10-31 Thread Marc van Grootel
Hi,

Any reason why the deault semantics for map:merge in 8.6 changed in a
backwards incompatible manner? Is this because of some XQuery/XPath
spec thing? A while ago I switched to 8.6-SNAPSHOT just to be on the
latest and greatest and I starting seeing weird things in my code.
Initially I didn't bother to look at the docs as I didn't expect
map:merge to have changed. At some point I even thought map:merge was
broken in this snapshot. I often use map:merge for handling function
options and I add the defaults first and then user options. With 8.6
this default behaviour has changed and I would have to switch this
around or explicitly ask for 'use-last'. I can do but only by adding
map { 'duplicates': 'use-last' }. This means I will have code <= 8.5
and I need to have different code for > 8.5.
Was this intentional? If not then I would vote for re-instating
default behaviour (use-last).

Cheers,
--Marc


Re: [basex-talk] bug (?) in fn:serialize

2016-09-09 Thread Marc van Grootel
... just checked. When the node is from a document instance than
serialize does keep whitespace (with or without xml:space).

And this clears up a confusion I had about what an element constructor
is and what a direct element constructor is.

For fun I tried serialize(element e { '   ' }) which happily returns 

Somebody wants to write that book on XML/XSLT/XQuery and whitespace?
Title suggestion: "Whitespace matters"

--Marc


Re: [basex-talk] bug (?) in fn:serialize

2016-09-09 Thread Marc van Grootel
Hmm first I thought not a bug and that the fix would be to do

serialize(   )

but to my surprise this results in



(with CHOP = false)

That doesn't seem right.

Whereas

serialize()

does what you expect.

--Marc


Re: [basex-talk] csv:parse in the age of XQuery 3.1

2016-09-08 Thread Marc van Grootel
I'm currently dealing with CSV a lot as well. I tend to use the
format=map approach but not nearly as large as 22 MB CSV yet. I'm
wondering if, or how much more efficient it is to deal with this type
of data as arrays and map data structures versus XML. For most
processing I can leave serializing to XML to the very end. And if too
large I would probably also chunk it before storing the end result.

Intuitively I would think that dealing with CSV as maps/arrays should
be much faster and less memory intensive.


--Marc


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

2016-05-20 Thread 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] Basex on maven central

2016-05-13 Thread Marc van Grootel
Hi Lance,

Just add http://files.basex.org/maven and optionally
http://xqj.net/maven as additional repositories.
I don't find this very inconvenient. This repo gets all the latest
releases and snapshots right out of the oven.

Not sure why it's not uploaded to Central anymore though.

Cheers,
--Marc


On Thu, May 12, 2016 at 5:45 PM, Lance Java <lance.j...@googlemail.com> wrote:
> It seems that maven central is not up to date with the latest basex version.
> I see here that there's only version 7.3.1 whereas on the basex website the
> latest version is 8.4.4
>
> http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.basex%22
>
> Are there any plans to keep maven central up to date with basex releases?



-- 
--Marc


Re: [basex-talk] Function must not be updating error in 8.4.3 (not in 8.4.2)

2016-04-26 Thread Marc van Grootel
Hi Christian,

This morning wanted to get to the bottom of this but found that with
the latest snapshot (23/4) it is fixed (can still repro with 8.4.3 and
older snapshots like the 22/4 snapshot).

Unless you think it's worthwhile to try and get a minimal reproducible
case for 8.4.3 I can try but as far as this issue goes it seems to be
gone now.

Thanks,
--Marc


On Fri, Apr 22, 2016 at 3:36 PM, Marc van Grootel
<marc.van.groo...@gmail.com> wrote:
> Checked with this new snapshot. It's still occurring.
> Will do some more digging on monday.
>
> Thanks,
> --Marc
>
> On Fri, Apr 22, 2016 at 3:21 PM, Christian Grün
> <christian.gr...@gmail.com> wrote:
>> Difficult to tell ;) I checked the places where your error message is
>> triggered. Did you use updating functions in built-in XQuery functions
>> (for-each, apply, ...)? Does your query run through with the new
>> snapshot [1]?
>>
>> [1] http://files.basex.org/releases/latest/
>>
>>
>>
>>
>> On Fri, Apr 22, 2016 at 2:03 PM, Marc van Grootel
>> <marc.van.groo...@gmail.com> wrote:
>>> Hi,
>>>
>>> I'm sorry for the vague report. I can do more digging but it's
>>> happening deep inside some code and it's hard to pinpoint.
>>>
>>> In 8.4.3 I get the following error message:
>>>
>>> [XPTY0004] Function must not be updating: %updating 
>>> function($result,$tran
>>>
>>> In 8.4.2 and before the same code works as expected.
>>>
>>> What I can say that it's happening in a fold-left function which in
>>> it's body uses an xslt transform (using Saxon). I have
>>> MIXUPDATES=true. I'm not touching the database inside this code but I
>>> can say that the fn call in which the fold-left is located does
>>> contain a couple of db:* functions (but they are not in the active
>>> code path). That's all I can offer at the moment.
>>>
>>> I'm happy to do some more digging later but I wanted to post this just
>>> in case it gives someone a hunch and it's only introduced since 8.4.2.
>>> Also tried 8.4.4-SNAPSHOT and there it's broken too.
>>>
>>> Cheers,
>>> --Marc
>
>
>
> --
> --Marc



-- 
--Marc


[basex-talk] Function must not be updating error in 8.4.3 (not in 8.4.2)

2016-04-22 Thread Marc van Grootel
Hi,

I'm sorry for the vague report. I can do more digging but it's
happening deep inside some code and it's hard to pinpoint.

In 8.4.3 I get the following error message:

[XPTY0004] Function must not be updating: %updating function($result,$tran

In 8.4.2 and before the same code works as expected.

What I can say that it's happening in a fold-left function which in
it's body uses an xslt transform (using Saxon). I have
MIXUPDATES=true. I'm not touching the database inside this code but I
can say that the fn call in which the fold-left is located does
contain a couple of db:* functions (but they are not in the active
code path). That's all I can offer at the moment.

I'm happy to do some more digging later but I wanted to post this just
in case it gives someone a hunch and it's only introduced since 8.4.2.
Also tried 8.4.4-SNAPSHOT and there it's broken too.

Cheers,
--Marc


Re: [basex-talk] XQJ status

2016-04-05 Thread Marc van Grootel
Hi Hans-Jürgen,

Yes, that's what I am looking for. Will read that paper.

Thanks,
--Marc


On Tue, Apr 5, 2016 at 5:22 PM, Hans-Juergen Rennau <hren...@yahoo.de> wrote:
> Hi Marc,
>
> like you, I find the integration of XQuery results into other languages a
> most interesting topic, and I think it is a topic deserving more attention
> from the XML-community than it receives.
>
> I feel that the integration should completely hide the fact that XQuery is a
> different language than the host language, that is, the query results should
> be delivered in *exactly* that format which the host language programmer
> desires. From this perspective, XQuery plays the role of an information
> service to the host language application. The XQuery programmer is
> responsible for writing queries which deliver information as an XDM
> representation of the information desired by the, say, Java programmer. The
> query is designed to produce a result XDM which the host language
> infrastructure (high-level API) transforms into the desired "final" format
> without the application programmer ever being aware of the XDM origin. To
> achieve an unambiguous correspondance between XDM and non-XDM, the query may
> augment the result with additional XDM items ("meta items") providing meta
> data about how to transform the (primary) XDM items into host language items
> (e.g. meta items defining the mapping of an XML fragment to a host language
> map via XPath expressions, or segmenting the XDM sequence into subsequences
> corresponding to distinct host language items.)
>
> The key to all this is a high-level API which completely hides the
> conversions between host language types and the XDM. Such an infrastructure
> must be built upon a low-level API like XQJ or the equivalent s9api of Saxon
> - which bridges the host language type system and the XDM type systems. The
> higher level API is responsible for *all* conversions between host language
> type system and XDM. I suggest a long series of XQuery execution functions
> with known result types, like
>execQuery2string
>execQuery2strings(: returns String[] :)
>execQuery2int
>execQuery2ints (: returns int[] :)
>...
>execQuery2map_string_string
>execQuery2map_string_int
>...
>etcera!
>
> from which the host language programmer chooses. The choice is dictated by
> the actual query to be launched: each published query has a known signature
> described in terms of host language types like integer arrays and
> string-to-boolean maps. So any given query has to be launched with a
> particular variant of execQuery, and this query delivers the desired data
> type.
>
> The approach can be extended in various way, for example by supporting the
> delivery of complex containers of information ("info trays") consisting of
> named entries each one of which has its own and independent type ( [1] ).
>
> So in summary I believe there are very interesting possibilities of
> integrating XQuery seamlessly into other languages, and the foundation is a
> low-level API preserving XDM type information. All else can be built on
> that.
>
> Cheers,
> Hans-Jürgen
>
>
> [1]
> http://www.balisage.net/Proceedings/vol5/html/Rennau01/BalisageVol5-Rennau01.html#d64477e307
>
>
>



-- 
--Marc


Re: [basex-talk] XQJ status

2016-04-05 Thread Marc van Grootel
Hi Christian,

Thanks. Very curious to hear about XQJ's fate.

I am currently using BaseX for data integration which got me thinking
about integration of XQuery in other web applications
(node/python/clojure etc.). I was triggered by the recent thread about
node-basex[1] and Hans Jürgen and your Balisage paper [2]. I was
considering what the most performant way would be to return XQuery
results as native types. Eg. function returns an array with maps or
XML nodes and it gets converted to the host application's native data
types so the application can use the results as if they were native
data types.

Maybe the only viable way to tackle this *is* via HTTP and a smart
serialization (EDN[3] for example is such a, non-JSON, serialization
that includes type info) but I was thinking if there was an existing
lower-level way (without the BaseX HTTP layer). XQJ would enable this
(at least for XQuery < 3) but I have doubts if it would deserialize
non-atomic XDM values (like nested maps/arrays) as this is new to
XQuery 3, I didn't check but I figure that the BaseXClient on which it
is based also doesn't provide the XDM metadata for each nested item.

Just pondering how to bridge from XQuery to other languages.

[1]: 
http://www.mail-archive.com/basex-talk%40mailman.uni-konstanz.de/msg07882.html
[2]: 
http://www.balisage.net/Proceedings/vol15/html/Rennau01/BalisageVol15-Rennau01.html
[3]: https://github.com/edn-format/edn


On Tue, Apr 5, 2016 at 11:58 AM, Christian Grün
<christian.gr...@gmail.com> wrote:
> Hi Marc,
>
>> Is it right that the current XQJ driver for BaseX doesn't support
>> XQuery 3 syntax? Everytime I try to use a query that includes some of
>> the newer features it barks at me with Invalid XQuery syntax, syntax
>> does not pass static validation. Is there way to get around that, say,
>> when the result would not use these XQuery 3 data types?
>>
>> I'm wondering what the fate is of XQJ in general. Will it remain relevant?
>
> I decided to pass on your question directly to Charles Foster; he
> might be able to give you some outlook!
>
>> Also I am confused why files.basex /maven repo has XQJ driver 1.6.0
>> and xqj.net has 1.4.0 as the latest or what the difference is.
>
> I have sent a pull request to Charles’ repo; it may be included in the
> next version there.
>
>> The reason I was looking into XQJ was that it provides ways to get XDM
>> type info with the result. I would like to be able to deal with the
>> result from a query at a higher level than just strings. I've briefly
>> looked into BaseXClient.java which seems to be able to return XDM
>> metadata but then I saw that XQJ could do this out of the box.
>
> Right, that’s only possible with XQJ.
>
>> In general I would be interested to hear what the best way would be to
>> get a client to deal with query responses as native (client-side)
>> types (including hashmaps and arrays) instead of strings. Would it be
>> better to focus on using BaseXClient and forget about XQJ?
>
> From my perspective, it’s good to use XQuery whenever possible and use
> our Client Module to address BaseX server instances [1] ;)
>
> Cheers,
> Christian
>
> [1] http://docs.basex.org/wiki/Client_Module



-- 
--Marc


[basex-talk] XQJ status

2016-04-05 Thread Marc van Grootel
Hi,

Is it right that the current XQJ driver for BaseX doesn't support
XQuery 3 syntax? Everytime I try to use a query that includes some of
the newer features it barks at me with Invalid XQuery syntax, syntax
does not pass static validation. Is there way to get around that, say,
when the result would not use these XQuery 3 data types?

Also I am confused why files.basex /maven repo has XQJ driver 1.6.0
and xqj.net has 1.4.0 as the latest or what the difference is.

I'm wondering what the fate is of XQJ in general. Will it remain relevant?

The reason I was looking into XQJ was that it provides ways to get XDM
type info with the result. I would like to be able to deal with the
result from a query at a higher level than just strings. I've briefly
looked into BaseXClient.java which seems to be able to return XDM
metadata but then I saw that XQJ could do this out of the box.

In general I would be interested to hear what the best way would be to
get a client to deal with query responses as native (client-side)
types (including hashmaps and arrays) instead of strings. Would it be
better to focus on using BaseXClient and forget about XQJ?

Cheers,
--Marc


Re: [basex-talk] Setting base-dir for xquery:eval

2016-02-19 Thread Marc van Grootel
Wow. You guys don't stop to amaze. Chris's suggestion would've worked.
Andy's suggestion was what I actually had in mind when I wrote the
post.
So he reads my mind, Chris adds a new feature and all that before the
clock of 10 less than 12 hours after the post. And that, probably,
with a good night's sleep in between.

Of course I'll share what I have. I am creating it to better provide
testable documentation and examples for Origami (I'm still working on
it but work has kinda taken over the last few months).

Cheers,
--Marc


On Fri, Feb 19, 2016 at 9:51 AM, Christian Grün
<christian.gr...@gmail.com> wrote:
>> a base-uri set. I wonder if there is a case for adding   base-uri  to the
>> xquery:eval options map to handle this in a cleaner way?
>
> …now there is [1,2]. New features in the documentation will be marked
> with 8.5, but they will already available in the snapshots and patch
> versions.
>
> [1] http://docs.basex.org/wiki/XQuery_Module#xquery:eval
> [2] http://files.basex.org/releases/latest/
>
>
>
>> On 19 Feb 2016 07:10, "Marc van Grootel" <marc.van.groo...@gmail.com> wrote:
>>>
>>> Yes, exactly what I was after. Thanks and good night :)
>>>
>>> --Marc
>>>
>>> > On 18 feb. 2016, at 23:38, Christian Grün <christian.gr...@gmail.com>
>>> > wrote:
>>> >
>>> > Hi Marc,
>>> >
>>> >> when running xquery:eval with a string it will try to resolve paths
>>> >> relative to the code module and not relative to the file the string
>>> >> came from.
>>> >
>>> > You could add a base-uri declaration in your query:
>>> >
>>> >  let $uri := 'a/b/c'
>>> >  let $query := '1'
>>> >  return xquery:eval(
>>> >'declare base-uri "' || $uri || '"; ' || $query
>>> >  )
>>> >
>>> > Does this help?
>>> > Christian
>>> >
>>> >
>>> >> Ideally I would like to be able to set the base-dir for
>>> >> xquery:eval. The asciidoc file isn't always in the correct path
>>> >> relative to the module that I need to import.
>>> >>
>>> >> Other options I'm considering but are less ideal.
>>> >>
>>> >> - Manipulate the module import paths in the query string using regexps
>>> >> - Writing out to a temp file and then use xquery:parse-uri (but this
>>> >> is tricky as I may not want to clutter existing directories with
>>> >> tempfiles only to have the imports work).
>>> >>
>>> >> Unless there are better options I think I'll opt for string massaging
>>> >> using regexps. But maybe someone has a better idea.
>>> >>
>>> >> --Marc



-- 
--Marc


Re: [basex-talk] Setting base-dir for xquery:eval

2016-02-18 Thread Marc van Grootel
Yes, exactly what I was after. Thanks and good night :)

--Marc

> On 18 feb. 2016, at 23:38, Christian Grün <christian.gr...@gmail.com> wrote:
> 
> Hi Marc,
> 
>> when running xquery:eval with a string it will try to resolve paths
>> relative to the code module and not relative to the file the string
>> came from.
> 
> You could add a base-uri declaration in your query:
> 
>  let $uri := 'a/b/c'
>  let $query := '1'
>  return xquery:eval(
>'declare base-uri "' || $uri || '"; ' || $query
>  )
> 
> Does this help?
> Christian
> 
> 
>> Ideally I would like to be able to set the base-dir for
>> xquery:eval. The asciidoc file isn't always in the correct path
>> relative to the module that I need to import.
>> 
>> Other options I'm considering but are less ideal.
>> 
>> - Manipulate the module import paths in the query string using regexps
>> - Writing out to a temp file and then use xquery:parse-uri (but this
>> is tricky as I may not want to clutter existing directories with
>> tempfiles only to have the imports work).
>> 
>> Unless there are better options I think I'll opt for string massaging
>> using regexps. But maybe someone has a better idea.
>> 
>> --Marc


[basex-talk] Setting base-dir for xquery:eval

2016-02-18 Thread Marc van Grootel
Hi,

I am having quite some fun with xquery:eval. I am working on a little
module for executable documentation (similar to Python doctest). I
want to write documentation in asciidoc, parse it and execute source
code blocks inside the asciidoc. Parsing works by calling asciidocj
and so far I can run simple queries, evaluate them, compare them with
an expected outcome and write the result back as evaluated asciidoc.

Now I want to tackle more advanced queries that import modules. But
when running xquery:eval with a string it will try to resolve paths
relative to the code module and not relative to the file the string
came from. Ideally I would like to be able to set the base-dir for
xquery:eval. The asciidoc file isn't always in the correct path
relative to the module that I need to import.

Other options I'm considering but are less ideal.

- Manipulate the module import paths in the query string using regexps
- Writing out to a temp file and then use xquery:parse-uri (but this
is tricky as I may not want to clutter existing directories with
tempfiles only to have the imports work).

Unless there are better options I think I'll opt for string massaging
using regexps. But maybe someone has a better idea.

--Marc


Re: [basex-talk] get and extract .gz files from web

2016-01-27 Thread Marc van Grootel
Hi Andy,

Nice use of syntax (though you have to loose the semi-colon of course).

Visually i like the arrow operator a lot. Looks like a visual pipeline

"https://wiki.mozilla.org/images/f/ff/Example.json.gz;
=> fetch:binary()
=> archive:extract-text()

I also think that this could be a bug or at least a good improvement
to make as the docs say gzip archives can be created. Christian, you
think we should file an issue for this?

--Marc

On Tue, Jan 26, 2016 at 9:51 PM, Andy Bunce <bunce.a...@gmail.com> wrote:
> Hi Marco,
>
> I get the same. This works:
>
> 
> "https://wiki.mozilla.org/images/f/ff/Example.json.gz;
> !fetch:binary(.)
> !archive:extract-text(.)
> 
>
> But this returns empty:
>
> 
> "https://wiki.mozilla.org/images/f/ff/Example.json.gz;
> !fetch:binary(.)
> !archive:entries(.)
>
> http://basex.org/modules/archive"/>
> 
>
> Expecting to see "example.json"
>
> Could this be a bug?
>
> /Andy
>
>
>
> On 26 January 2016 at 18:51, Maximilian Gärber <mgaer...@arcor.de> wrote:
>>
>> Hi,
>>
>> I think this should work, I use it for OData requests from IIS.
>>
>> Need to dig through the source...but I used one oft the extract-binary
>> functions
>>
>> Regards, Max
>>
>> Am 26.01.2016 16:04 schrieb "Marc van Grootel"
>> <marc.van.groo...@gmail.com>:
>>>
>>> Well, shelling out wasn't so hard even on Windows with cygwin tools it's
>>> simply
>>>
>>> proc:execute('gunzip', $path-to-gzipped-file)
>>>
>>> Worked quite transparently as it extracts the files and removes the
>>> .gz file. Would be nice if there's a pure XQuery solution but for now
>>> I'm okay.
>>>
>>> Cheers,
>>>
>>> On Tue, Jan 26, 2016 at 3:13 PM, Marc van Grootel
>>> <marc.van.groo...@gmail.com> wrote:
>>> > Hi,
>>> >
>>> > I hoped that I could use archive module to also extract gzipped files.
>>> > I need to fetch/sync large XML from a web service that has the option
>>> > of getting files with gzip encoding (to be nice to the web server).
>>> >
>>> > First attempt was to explicitly get the gz file via the URL and then
>>> > treat it like an archive binary (extracting it with the recipe from
>>> > the archive module page). The entries XML I get is empty so I suppose
>>> > that I cannot read .gz
>>> >
>>> > Second attempt was to specify Accept-Encoding = gzip which indeed
>>> > delivers the XML as a binary. But I probably run into the same issue
>>> > when trying to extract.
>>> >
>>> > Is there a way to do the extraction of .gz encoded files without
>>> > having to shell out to some kind of unzipper?
>>> >
>>> > Cheers,
>>> > --Marc
>>>
>>>
>>>
>>> --
>>> --Marc
>
>



-- 
--Marc


[basex-talk] get and extract .gz files from web

2016-01-26 Thread Marc van Grootel
Hi,

I hoped that I could use archive module to also extract gzipped files.
I need to fetch/sync large XML from a web service that has the option
of getting files with gzip encoding (to be nice to the web server).

First attempt was to explicitly get the gz file via the URL and then
treat it like an archive binary (extracting it with the recipe from
the archive module page). The entries XML I get is empty so I suppose
that I cannot read .gz

Second attempt was to specify Accept-Encoding = gzip which indeed
delivers the XML as a binary. But I probably run into the same issue
when trying to extract.

Is there a way to do the extraction of .gz encoded files without
having to shell out to some kind of unzipper?

Cheers,
--Marc


Re: [basex-talk] get and extract .gz files from web

2016-01-26 Thread Marc van Grootel
Well, shelling out wasn't so hard even on Windows with cygwin tools it's simply

proc:execute('gunzip', $path-to-gzipped-file)

Worked quite transparently as it extracts the files and removes the
.gz file. Would be nice if there's a pure XQuery solution but for now
I'm okay.

Cheers,

On Tue, Jan 26, 2016 at 3:13 PM, Marc van Grootel
<marc.van.groo...@gmail.com> wrote:
> Hi,
>
> I hoped that I could use archive module to also extract gzipped files.
> I need to fetch/sync large XML from a web service that has the option
> of getting files with gzip encoding (to be nice to the web server).
>
> First attempt was to explicitly get the gz file via the URL and then
> treat it like an archive binary (extracting it with the recipe from
> the archive module page). The entries XML I get is empty so I suppose
> that I cannot read .gz
>
> Second attempt was to specify Accept-Encoding = gzip which indeed
> delivers the XML as a binary. But I probably run into the same issue
> when trying to extract.
>
> Is there a way to do the extraction of .gz encoded files without
> having to shell out to some kind of unzipper?
>
> Cheers,
> --Marc



-- 
--Marc


Re: [basex-talk] Embedding BaseX in Clojure web app, pointers needed

2016-01-19 Thread Marc van Grootel
Yes, Clojure has very good Java interop. I lean towards embedding too
as it gives much more control over BaseX and I want it to become an
integral part of the webapp.

On Tue, Jan 19, 2016 at 10:49 AM, Dirk Kirsten <d...@basex.org> wrote:
> Hello Marc,
>
> I have no idea how Clojure works (but would be very interested, but time
> is a scarce resource...), but according to
> https://clojuredocs.org/clojure.core/import you should be able to simply
> import Java classes/libraries. If this is possible it should be a simple
> process: Put the BaseX.jar into the library path and import the
> necessary classes (you can take a look at our Java examples in the wiki,
> should work the same).
>
> Well, if your pirgamm is not client/server oriented I would definitely
> try to embed BaseX. The main benefit of the BaseX Client/Server version
> is that you can access it with multiple processes at the same time. Of
> course, the client version is theoretically slower (it has to send stuff
> over sockets, It has to create/parse TCP packets and it might be a
> significant overhead to use TCP if you have a rather small query or
> result set. But this overhead could also be insignificant, if you don't
> have this and your client/server have a fast connection (i.e. on the
> same server or the same network).
>
> Cheers
> Dirk
>
> On 01/18/2016 11:49 PM, Marc van Grootel wrote:
>> Hi,
>>
>> I'm considering to write a web layer for BaseX based in Clojure. It
>> may be a somewhat longer term project but I would like to bring XML
>> and BaseX closer to Clojure programming. Clojure web apps usually are
>> able to run under various servers/containers (Jetty/Netty etc.) and I
>> would like to be able to use Clojure libraries to handle things like
>> request routing, security and authentication outside of BaseX/XQuery.
>>
>> Some questions that I have while I'm orienting myself. Some of it
>> touches on integration areas that are quite new to me so I am happy to
>> get some general pointers that I can use to dig further.
>>
>> For Clojure I found only one BaseX client library [1] which wraps the
>> standard Java TCP client and it seems to work fine.
>>
>> But I have some broader questions such as
>>
>> - Choosing between using the client or much more intimately embedding
>> BaseX as a library. The latter is probably much more complex but I'm
>> figuring this is the only way to get a good integration as the TCP
>> client is rather limited in functionality. But where to start? What
>> layers of the existing servlet integration to peel off, which ones to
>> keep. Is BaseXServer.java a good starting point?
>>
>> - Is the TCP client generally slower than via the Java API? A couple
>> of queries via clj-basex didn't impress me much qua speed (compared to
>> same query via the GUI).
>>
>> Any starting points or general considerations that could help me prune
>> the (re)search tree are very much appreciated.
>>
>>
>> --Marc
>>
>> [1] https://github.com/kouphax/clj-basex
>
> --
> 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 91 68 276, Fax: 0049 7531 20 05 22
>



-- 
--Marc


Re: [basex-talk] xquery:eval bug?

2016-01-19 Thread Marc van Grootel
And I can confirm that my code now also runs when MIXUPDATES=true

Although the code isn't meant to be shared yet as it's very much WIP
here's the example I"m running:
https://github.com/xokomola/origami-examples/blob/master/check/check-demo.xq

It's running all the Origami test cases via a custom built test
harness (tests are evaluated via xquery:eval).

--Marc

On Mon, Jan 18, 2016 at 1:51 PM, Christian Grün
<christian.gr...@gmail.com> wrote:
> Hi Marc, hi Andy,
>
> Confirmed, it seems to be the MIXUPDATES option. Once again, I noticed
> it’s tricky to statically detect which dynamic function calls will
> perform updates. Obviously, in the given case, there was no updating
> code at all, so the error message was a bit misleading.
>
> Feedback on the MIXUPDATES option is always welcome. I have just
> uploaded a new snapshot [1].
>
> Christian
>
> [1] http://files.basex.org/releases/latest/
>
>
>
> On Mon, Jan 18, 2016 at 12:58 PM, Marc van Grootel
> <marc.vangroo...@theapsgroup.com> wrote:
>> Hi Christian,
>>
>> Yes, I think so. I think MIXUPDATES=true could be the difference. I almost 
>> forgot about these as I always run basex from a Gradle script which sets 
>> these [1]
>>
>> [1] 
>> https://github.com/theapsgroup/basex-gradle-starter/blob/master/gradle.properties
>>
>> -Original Message-
>> From: basex-talk-boun...@mailman.uni-konstanz.de 
>> [mailto:basex-talk-boun...@mailman.uni-konstanz.de] On Behalf Of Christian 
>> Grün
>> Sent: Monday, January 18, 2016 11:32 AM
>> To: Marc van Grootel <marc.van.groo...@gmail.com>
>> Cc: BaseX <basex-talk@mailman.uni-konstanz.de>
>> Subject: Re: [basex-talk] xquery:eval bug?
>>
>> Hi Marc,
>>
>> It runs fine on my environment. Could you give me some more information on 
>> your set up (have you assigned any non-default options)?
>>
>> Christian
>>
>>
>> On Mon, Jan 18, 2016 at 10:07 AM, Marc van Grootel 
>> <marc.van.groo...@gmail.com> wrote:
>>> Hi Christian,
>>>
>>> Seems to work fine with latest snapshot with some straightforward
>>> cases but I do get an error in some cases which I cannot understand.
>>> Though I appreciate that it may be difficult to support all types of
>>> dynamic calls.
>>>
>>> The error is: [bxerr:BXXQ0001] No updating expression allowed.
>>>
>>> I am not using updating expressions. I also tried this in my little
>>> test project and it runs against the same error. I haven't been able
>>> to pinpoint it yet as it happens deep in the bowels of the code. When
>>> I'm able to I will let you know.
>>>
>>> You can use a simple/small set of unit tests to verify [1]. I've
>>> %unit:ignored the last test that causes the error above.
>>>
>>> Cheers,
>>> --Marc
>>>
>>> [1]
>>> https://github.com/xokomola/origami-examples/blob/master/check/test-ev
>>> al.xqm
>>>
>>> On Fri, Jan 15, 2016 at 6:57 PM, Christian Grün
>>> <christian.gr...@gmail.com> wrote:
>>>> Hi Marc,
>>>>
>>>> This was a deliberate restriction: As maps and arrays are function
>>>> items, and as they can contain references to other functions that
>>>> have been declared in the evaluated query, it is generally tricky to
>>>> evaluate and return them dynamically.
>>>>
>>>> However, I spent some more thoughts on the underlying semantics, and
>>>> I may have found a solution that overcomes some of the earlier
>>>> limitations.
>>>>
>>>> A new snapshot is available [1], which now allows you to return
>>>> function items (incl. maps and arrays) as result of xquery:eval. Your
>>>> testing feedback will be welcome.
>>>>
>>>> Christian
>>>>
>>>> [1] http://files.basex.org/releases/latest/
>>>>
>>>>
>>>>
>>>> On Thu, Jan 14, 2016 at 11:17 PM, Marc van Grootel
>>>> <marc.van.groo...@gmail.com> wrote:
>>>>> Hi,
>>>>>
>>>>> I'm trying to return a map or an array from xquery:eval. Seems this
>>>>> is not possible, yet the signature says it returns item()*
>>>>>
>>>>> xquery:eval('1 + 1') => 2
>>>>> xquery:eval('[1,2]') => ERROR: [FOTY0014] Items of type array(*)
>>>>> have no string representation.
>>>>> xquery:eval('map { "x": 10 }') => ERROR: [FOTY0014] 

Re: [basex-talk] xquery:eval bug?

2016-01-18 Thread Marc van Grootel
Hi Christian,

Seems to work fine with latest snapshot with some straightforward
cases but I do get an error in some cases which I cannot understand.
Though I appreciate that it may be difficult to support all types of
dynamic calls.

The error is: [bxerr:BXXQ0001] No updating expression allowed.

I am not using updating expressions. I also tried this in my little
test project and it runs against the same error. I haven't been able
to pinpoint it yet as it happens deep in the bowels of the code. When
I'm able to I will let you know.

You can use a simple/small set of unit tests to verify [1]. I've
%unit:ignored the last test that causes the error above.

Cheers,
--Marc

[1] https://github.com/xokomola/origami-examples/blob/master/check/test-eval.xqm

On Fri, Jan 15, 2016 at 6:57 PM, Christian Grün
<christian.gr...@gmail.com> wrote:
> Hi Marc,
>
> This was a deliberate restriction: As maps and arrays are function
> items, and as they can contain references to other functions that have
> been declared in the evaluated query, it is generally tricky to
> evaluate and return them dynamically.
>
> However, I spent some more thoughts on the underlying semantics, and I
> may have found a solution that overcomes some of the earlier
> limitations.
>
> A new snapshot is available [1], which now allows you to return
> function items (incl. maps and arrays) as result of xquery:eval. Your
> testing feedback will be welcome.
>
> Christian
>
> [1] http://files.basex.org/releases/latest/
>
>
>
> On Thu, Jan 14, 2016 at 11:17 PM, Marc van Grootel
> <marc.van.groo...@gmail.com> wrote:
>> Hi,
>>
>> I'm trying to return a map or an array from xquery:eval. Seems this is
>> not possible, yet the signature says it returns item()*
>>
>> xquery:eval('1 + 1') => 2
>> xquery:eval('[1,2]') => ERROR: [FOTY0014] Items of type array(*)
>> have no string representation.
>> xquery:eval('map { "x": 10 }') => ERROR: [FOTY0014] Items of type
>> map(*) have no string representation.
>>
>> BTW: I saw that xquery:eval#3 is documented as returning item() while
>> the other arities return item()*
>>
>> Tested on 8.3, haven't tested yet on 8.4beta but it's trivial to repro I 
>> figure.
>>
>> --
>> --Marc



-- 
--Marc


Re: [basex-talk] xquery:eval bug?

2016-01-18 Thread Marc van Grootel
Hi Christian,

Yes, I think so. I think MIXUPDATES=true could be the difference. I almost 
forgot about these as I always run basex from a Gradle script which sets these 
[1]

[1] 
https://github.com/theapsgroup/basex-gradle-starter/blob/master/gradle.properties

-Original Message-
From: basex-talk-boun...@mailman.uni-konstanz.de 
[mailto:basex-talk-boun...@mailman.uni-konstanz.de] On Behalf Of Christian Grün
Sent: Monday, January 18, 2016 11:32 AM
To: Marc van Grootel <marc.van.groo...@gmail.com>
Cc: BaseX <basex-talk@mailman.uni-konstanz.de>
Subject: Re: [basex-talk] xquery:eval bug?

Hi Marc,

It runs fine on my environment. Could you give me some more information on your 
set up (have you assigned any non-default options)?

Christian


On Mon, Jan 18, 2016 at 10:07 AM, Marc van Grootel <marc.van.groo...@gmail.com> 
wrote:
> Hi Christian,
>
> Seems to work fine with latest snapshot with some straightforward
> cases but I do get an error in some cases which I cannot understand.
> Though I appreciate that it may be difficult to support all types of
> dynamic calls.
>
> The error is: [bxerr:BXXQ0001] No updating expression allowed.
>
> I am not using updating expressions. I also tried this in my little
> test project and it runs against the same error. I haven't been able
> to pinpoint it yet as it happens deep in the bowels of the code. When
> I'm able to I will let you know.
>
> You can use a simple/small set of unit tests to verify [1]. I've
> %unit:ignored the last test that causes the error above.
>
> Cheers,
> --Marc
>
> [1]
> https://github.com/xokomola/origami-examples/blob/master/check/test-ev
> al.xqm
>
> On Fri, Jan 15, 2016 at 6:57 PM, Christian Grün
> <christian.gr...@gmail.com> wrote:
>> Hi Marc,
>>
>> This was a deliberate restriction: As maps and arrays are function
>> items, and as they can contain references to other functions that
>> have been declared in the evaluated query, it is generally tricky to
>> evaluate and return them dynamically.
>>
>> However, I spent some more thoughts on the underlying semantics, and
>> I may have found a solution that overcomes some of the earlier
>> limitations.
>>
>> A new snapshot is available [1], which now allows you to return
>> function items (incl. maps and arrays) as result of xquery:eval. Your
>> testing feedback will be welcome.
>>
>> Christian
>>
>> [1] http://files.basex.org/releases/latest/
>>
>>
>>
>> On Thu, Jan 14, 2016 at 11:17 PM, Marc van Grootel
>> <marc.van.groo...@gmail.com> wrote:
>>> Hi,
>>>
>>> I'm trying to return a map or an array from xquery:eval. Seems this
>>> is not possible, yet the signature says it returns item()*
>>>
>>> xquery:eval('1 + 1') => 2
>>> xquery:eval('[1,2]') => ERROR: [FOTY0014] Items of type array(*)
>>> have no string representation.
>>> xquery:eval('map { "x": 10 }') => ERROR: [FOTY0014] Items of
>>> type
>>> map(*) have no string representation.
>>>
>>> BTW: I saw that xquery:eval#3 is documented as returning item()
>>> while the other arities return item()*
>>>
>>> Tested on 8.3, haven't tested yet on 8.4beta but it's trivial to repro I 
>>> figure.
>>>
>>> --
>>> --Marc
>
>
>
> --
> --Marc

__
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com 
__
'**
This E-mail and any files transmitted with it are private and confidential and 
are solely for the use of the addressee.  It may contain material which is 
legally privileged.  If you are not the addressee, be advised that you have 
received this E-mail in error and that any use of it is strictly prohibited.

If you have received this E-mail in error, please notify APS on +44 (0)161 495 
4500, or E-mail administra...@theapsgroup.com.
Any opinions expressed in the E-mail are those of the individual writer of it 
and not necessarily the Company unless specifically stated otherwise.  There is 
no intention to create any legally binding contract or other commitment through 
use of this E-mail

We cannot accept any liability for any loss or damage sustained as a result of 
software viruses.  It is your responsibility to carry out such virus checking 
as is necessary before downloading this E-mail and any attachments onto your 
computer system.

Allied Publicity Services (Man

[basex-talk] Embedding BaseX in Clojure web app, pointers needed

2016-01-18 Thread Marc van Grootel
Hi,

I'm considering to write a web layer for BaseX based in Clojure. It
may be a somewhat longer term project but I would like to bring XML
and BaseX closer to Clojure programming. Clojure web apps usually are
able to run under various servers/containers (Jetty/Netty etc.) and I
would like to be able to use Clojure libraries to handle things like
request routing, security and authentication outside of BaseX/XQuery.

Some questions that I have while I'm orienting myself. Some of it
touches on integration areas that are quite new to me so I am happy to
get some general pointers that I can use to dig further.

For Clojure I found only one BaseX client library [1] which wraps the
standard Java TCP client and it seems to work fine.

But I have some broader questions such as

- Choosing between using the client or much more intimately embedding
BaseX as a library. The latter is probably much more complex but I'm
figuring this is the only way to get a good integration as the TCP
client is rather limited in functionality. But where to start? What
layers of the existing servlet integration to peel off, which ones to
keep. Is BaseXServer.java a good starting point?

- Is the TCP client generally slower than via the Java API? A couple
of queries via clj-basex didn't impress me much qua speed (compared to
same query via the GUI).

Any starting points or general considerations that could help me prune
the (re)search tree are very much appreciated.


--Marc

[1] https://github.com/kouphax/clj-basex


[basex-talk] xquery:eval bug?

2016-01-14 Thread Marc van Grootel
Hi,

I'm trying to return a map or an array from xquery:eval. Seems this is
not possible, yet the signature says it returns item()*

xquery:eval('1 + 1') => 2
xquery:eval('[1,2]') => ERROR: [FOTY0014] Items of type array(*)
have no string representation.
xquery:eval('map { "x": 10 }') => ERROR: [FOTY0014] Items of type
map(*) have no string representation.

BTW: I saw that xquery:eval#3 is documented as returning item() while
the other arities return item()*

Tested on 8.3, haven't tested yet on 8.4beta but it's trivial to repro I figure.

-- 
--Marc


Re: [basex-talk] Automatically generating test cases. Hidden feature?

2016-01-13 Thread Marc van Grootel
The compliment is well-deserved ;-)

Yes, after my mind settled down on what I wrote, I realized this too.
The annotation nor the anonymous function itself (a partial could have
served the same function) wasn't necessary. So it's just plain cool
instead of very cool.

It was mostly my sudden enthousiasm for the possibilities this
approach opens for an alternative testing approach. I always thought
about the unit module as having to write an explicit test suite with
the unit annotations and never realized that the unit:assert functions
can very well be used on their own. In my case in the context of
generative/property-based testing.


Cheers,
--Marc



On Wed, Jan 13, 2016 at 8:43 AM, Christian Grün
<christian.gr...@gmail.com> wrote:
> Hi Marc,
>
>> BaseX, the gift that keeps on giving, thanks to all that make it possible.
>
> One of the nicest compliments that we got so far… Thanks ;)
>
>> So, a bit to my amazement, the following works:
>>
>> let $equals :=
>>   %unit:test
>>   function($a,$b) {
>> unit:assert-equals($a,$b, 'Not equal')
>>   }
>> return
>>   $equals(4,3)
>
> Yes, it does, it will do so in the future. To add some more surprises:
> You can omit the %unit:test annotation, because it’s the
> unit:assert-equals function that raises the error in the XQUnit
> namespace.
>
> Cheers,
> Christian



-- 
--Marc


[basex-talk] Automatically generating test cases. Hidden feature?

2016-01-12 Thread Marc van Grootel
Hi,

Been a long time since posting. Work is very busy recently. Luckily
for me a lot of it involves XQuery ;-)

I am elaborating some examples [1] that show off the use of my Origami
[2] library. The most promising ones I will turn in to blog posts or a
wiki at some point.

Recently I've been reading a bit about generative testing (or
property-based testing) and libraries like Haskell's QuickCheck. I
hope to be able to show that we can use such techniques in combination
with RelaxNG and the concepts that Eric van der Vlist describes in
Examplotron [3] to mutate XML instances guided by a schema that I can
then turn into automatically generated tests.

It's still early days and time is limited but I did stumble onto
something interesting that I wanted to share here. If you already use
similar techniques I would be very interested to hear about it.

I was contemplating if it was possible to create anonymous unit test
functions that I can invoke with generated test input.

So, a bit to my amazement, the following works:

let $equals :=
  %unit:test
  function($a,$b) {
unit:assert-equals($a,$b, 'Not equal')
  }
return
  $equals(4,3)

This function raises the unit:UNIT0001 exception with the message
"Item 1: 3 expected, 4 returned". Cool!

So if this is possible can we also catch a failure and turn it into data?

let $equals :=
  %unit:test
  function($a,$b) {
unit:assert-equals($a,$b, 'Not equal')
  }
return
  try {
$equals(4,3)
  } catch * {

  { $err:code }
  { $err:description }
  { $err:value }
  { $err:module }
  { $err:line-number }
  { $err:column-number }

  }

This too works and produces an XML fragment recording the failure. Very cool!


  unit:UNIT0001
  Item 1: 3 expected, 4 returned.
  Not equal
  .../origami-examples/check/demo.xq
  23
  24


I am not sure if this a hidden or an intentional feature of the BaseX
unit module. I sure hope that it doesn't go away in future releases as
I intend to leverage this in an alternative testing module.

BaseX, the gift that keeps on giving, thanks to all that make it possible.

--Marc

[1] https://github.com/xokomola/origami-examples
[2] https://github.com/xokomola/origami
[3] http://examplotron.org/


Re: [basex-talk] Generating consecutive integers in a for loop

2015-10-22 Thread Marc van Grootel
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.gr...@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.stap...@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


[basex-talk] Origami presentation XML Amsterdam

2015-09-29 Thread Marc van Grootel
Hi,

Anyone on the list coming to Amsterdam the 6th of November? We may have some 
beers together.

I will (finally) be presenting on the Origami templating library. I'm still 
working on it over on Github (in the unstable branch). After a pause in 
development it was almost completely rewritten. I intend to cut a new release 
just before the conference.

Here's the anouncement I made for the conference website.

XQuery 3.1 is still a candidate for recommendation by the W3C. Nevertheless 
there are already various implementations ready for use today. The introduction 
of maps and arrays, and the availability of functional weaponry such as fold 
and apply may change the way you write XQuery applications. You can still wield 
the trusty weapons of XPath and the FLWOR expression while, at the same time, 
adopting a more functional style of programming.

Origami is an ongoing exploration of templating in XQuery and it makes heavy 
use of this functional style. It started with a quest for a more XSLT-like 
transformation capability and recently took a nice turn with the adoption of a 
flavor of micro-XML, with a heavy reliance on maps and arrays. Origami's 
unfolding design tries to honour principles of simplicity and composability. 
With Origami I aim to decomplect, or disentangle, several aspects common to 
templating problems and offer them in a powerful library using a couple of 
simple abstractions.

With some practical code examples I will demonstrate how to use Origami to 
implement different templating styles. 


--Marc

Re: [basex-talk] Xquery collections

2015-09-15 Thread Marc

Hi Michele,
Is it not because the following axis do'nt return the childrens?
Do you try without the except to see if you have all your text()?
Marc

Le 04/09/2015 15:49, michele.gre...@email.it a écrit :

Hi, i tried this xquery:
for $e in db:open("dbName")//w:tc[.//text()="Nome"]
  return $e/./following::text()except
   (for $x in db:open("dbName")//w:tc[.//text()="Indirizzo"]
return $x//following::text())
but only returns the result of the first document.
How do i do it for all the documents?

- Original Message 
Da: "Dirk Kirsten" <d...@basex.org>
To:
Cc: basex-talk@mailman.uni-konstanz.de
Oggetto: Re: [basex-talk] Xquery collections
Data: 03/09/15 18:08

Ciao Michele,

welcome to the community :-)

Collections in BaseX are basically databases. You can simply open a
database e.g. by issueing the XQuery db:open('mydatabase'). This
will use all documents in your database.

You can find some more examples at http://docs.basex.org/wiki/Databases

It might also be helpful for you to read some of the Tutorials given
at http://docs.basex.org/wiki/Getting_Started like BaseX for
Dummies, given a concise introduction to BaseX.

Spero che sia d'aiuto
Dirk



On 09/03/2015 05:48 PM, michele.gre...@email.it wrote:

Hello I Michele i'm new to basex,
i created a collection with different documents .xml.
I want to know how to query the entire collection e its
documents at one xquery.
I'm trying,but i can't.
Thanks.
MG


ZE-Light e ZE-Pro: servizi zimbra per caselle con dominio
email.it, per tutti i dettagli clicca qui

<http://posta.email.it/caselle-di-posta-z-email-it/?utm_campaign=email_Zimbra_102014=main_footer>

Sponsor:
Idee regalo classiche o alternative? Trova l'offerta migliore in
un click
Clicca qui
<http://adv.email.it/cgi-bin/foclick.cgi?mid=13327=20150903>


-- 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



ZE-Light e ZE-Pro: servizi zimbra per caselle con dominio email.it, per
tutti i dettagli clicca qui
<http://posta.email.it/caselle-di-posta-z-email-it/?utm_campaign=email_Zimbra_102014=main_footer>

Sponsor:
Caselle con tuo dominio su piattaforma Zimbra, fino a 30 GB di spazio,
sincronizzazione dati e backup
Clicca qui <http://adv.email.it/cgi-bin/foclick.cgi?mid=13324=20150904>


Re: [basex-talk] size on collection in the time

2015-09-03 Thread Marc

James,
We have the UPDINDEX to FALSE.
I'll try to do an OPTIMIZE command, but we do it at the end of all the 
REPLACE so I think that it's not enough.

After that I prepare a study case with public data.
Regards
Marc

Le 03/09/2015 12:17, James Ball a écrit :

Marc,

Are you using the updatable index? UPDINDEX true.

If so, if you look back through the list Christian and I had an exchange on 
this as I was experiencing an ever growing index - a replace always appended to 
the end of the index. IIRC the logic is a bit better now in that if on a 
replace there is enough room in the index structure to reuse slots it will, but 
if not it will be appended. And the db will reuse empty slots while the 
database remains open. I can’t remember which is the first version where this 
change was made, sorry.

I had a DB the other day that had got to 14GB but was only around 600MB once I 
did a full optimise. My suggestion is next time to try a full optimise instead 
of dropping the collection and see if that helps.

Regards, James



Message: 1
Date: Wed, 2 Sep 2015 17:36:19 +0200
From: Marc <marc.li...@free.fr>
To: BaseX <basex-talk@mailman.uni-konstanz.de>
Subject: [basex-talk] size on collection in the time
Message-ID: <55e71773.7050...@free.fr>
Content-Type: text/plain; charset=iso-8859-15; format=flowed

Hi,
I have a remark about the size of the files of a collection.
We do a lot of updates (REPLACE) with an attributes index but without a
text index.
I see that the size of the files grows up in the time we arrive until
30Go until the limit of the filessytems quota.
When I drop the collection and recreate it from the last version of the
files the size was only 6Go.

We will redo the test with the time, but I just want to know if the
program clears the disk use when he does a REPLACE?

Marc


Re: [basex-talk] size on collection in the time

2015-09-03 Thread Marc

Hello Dirk,
We use a BaseX script (.xbs) with a list of REPLACE.
We try to investigate this point if this is reproducable or not.
If I find this problem again, I take a copy of the collection before to 
delete her.


Thank you for answer.

Marc
Le 03/09/2015 09:52, Dirk Kirsten a écrit :

Hello Marc,

sure, a replace should lead to a true replace, i.e. the old data will be
dropped. So this sounds like a bug, but it is difficult to replicate
from what you describe.

Do you think it would be possible to make the issue reproducable, maybe
also with a smaller data set? Also, how exactly do you add documents or
do you also do any queries and maybe other updating queries?

Cheers
Dirk

On 09/02/2015 05:36 PM, Marc wrote:

Hi,
I have a remark about the size of the files of a collection.
We do a lot of updates (REPLACE) with an attributes index but without
a text index.
I see that the size of the files grows up in the time we arrive until
30Go until the limit of the filessytems quota.
When I drop the collection and recreate it from the last version of
the files the size was only 6Go.

We will redo the test with the time, but I just want to know if the
program clears the disk use when he does a REPLACE?

Marc




Re: [basex-talk] (no subject)

2015-09-03 Thread Marc


I forgot to give this precision, we use the 7.9 version on this server.

Marc
Le 01/01/1970 01:00,  a écrit :

Hello Dirk,
We use a BaseX script (.xbs) with a list of REPLACE.
We try to investigate this point if this is reproducable or not.
If I find this problem again, I take a copy of the collection before to
delete her.

Thank you for answer.

Marc
Le 03/09/2015 09:52, Dirk Kirsten a écrit :

Hello Marc,

sure, a replace should lead to a true replace, i.e. the old data will be
dropped. So this sounds like a bug, but it is difficult to replicate
from what you describe.

Do you think it would be possible to make the issue reproducable, maybe
also with a smaller data set? Also, how exactly do you add documents or
do you also do any queries and maybe other updating queries?

Cheers
Dirk

On 09/02/2015 05:36 PM, Marc wrote:

Hi,
I have a remark about the size of the files of a collection.
We do a lot of updates (REPLACE) with an attributes index but without
a text index.
I see that the size of the files grows up in the time we arrive until
30Go until the limit of the filessytems quota.
When I drop the collection and recreate it from the last version of
the files the size was only 6Go.

We will redo the test with the time, but I just want to know if the
program clears the disk use when he does a REPLACE?

Marc




[basex-talk] size on collection in the time

2015-09-02 Thread Marc

Hi,
I have a remark about the size of the files of a collection.
We do a lot of updates (REPLACE) with an attributes index but without a 
text index.
I see that the size of the files grows up in the time we arrive until 
30Go until the limit of the filessytems quota.
When I drop the collection and recreate it from the last version of the 
files the size was only 6Go.


We will redo the test with the time, but I just want to know if the 
program clears the disk use when he does a REPLACE?


Marc


[basex-talk] Trouble with wildcard lookup operator on maps?

2015-08-15 Thread Marc van Grootel
Hi,

Unless I'm not reading the spec[1] correctly then the following two
snippets should have the same result:

Example 1:


let $map := map { 'a': (1,2,3), 'b': (4,5,6)}
for $k in map:keys($map)
return array { $map($k) }

Example 2:

let $map := map { 'a': (1,2,3), 'b': (4,5,6)}
for $k in $map?*
return array { $k }

However, this is not the case. The first outputs, as I expected:

([1,2,3], [4,5,6])

The second, counter intuitively returns (on 8.2.3) this:

([1],[2],[3],[4],[5],[6])

The spec indicates that both examples result should be identical.
Didn't check if the same is going on with arrays.

Hmmm?

[1] http://www.w3.org/TR/xquery-31/#id-lookup


Re: [basex-talk] Trouble with wildcard lookup operator on maps?

2015-08-15 Thread Marc van Grootel
Hi Christian,

Ok, that clears it up. Somehow I suspected this, but I was thrown by
the statement in the spec (and my faulty intuition) that says:

If the KeySpecifier is a wildcard (*) and the context item is a map,
unary lookup is equivalent to the following expression:

  for $k in map:keys(.)
  return .($k)

I realize that if I didn't put an array {} around the return value
then this statement would be correct.

Just thought I caught a loophole there. I stand corrected. ;-)


On Sat, Aug 15, 2015 at 3:59 PM, Christian Grün
christian.gr...@gmail.com wrote:
 Hi Marc,

 The result is correct: The FOR clause of the FLWOR expression always
 binds one item at a time. If you want to bind sequences, you should
 use arrays in your map constructor:

   let $map := map { 'a': [1,2,3], 'b': [4,5,6] }
   return $map?*

 Hope this helps,
 Christian



 On Sat, Aug 15, 2015 at 3:47 PM, Marc van Grootel
 marc.van.groo...@gmail.com wrote:
 Hi,

 Unless I'm not reading the spec[1] correctly then the following two
 snippets should have the same result:

 Example 1:


 let $map := map { 'a': (1,2,3), 'b': (4,5,6)}
 for $k in map:keys($map)
 return array { $map($k) }

 Example 2:

 let $map := map { 'a': (1,2,3), 'b': (4,5,6)}
 for $k in $map?*
 return array { $k }

 However, this is not the case. The first outputs, as I expected:

 ([1,2,3], [4,5,6])

 The second, counter intuitively returns (on 8.2.3) this:

 ([1],[2],[3],[4],[5],[6])

 The spec indicates that both examples result should be identical.
 Didn't check if the same is going on with arrays.

 Hmmm?

 [1] http://www.w3.org/TR/xquery-31/#id-lookup



-- 
--Marc


[basex-talk] HTTP response and raising error()

2015-08-13 Thread Marc van Grootel
Hi,

Nothing major but I was wondering what the thinking was behind
returning a 400 when fn:error is raised. Basically that says client,
your mistake not mine where in most cases I guess a 500 would be more
appropriate.

Where is this decided (RESTXQ?) and is there an easy way to change the
status when fn:error is used?

Of course I can always catch at the highest level and then decide
which HTTP status to return but I'm not sure if I want to wrap all
REST calls in try / catch.

-- 
--Marc


Re: [basex-talk] HTTP response and raising error()

2015-08-13 Thread Marc van Grootel
Ah, ok. Didn't know about the third argument. I didn't realize that an
int as $error-object would be interpreted as returning that as status
code. Is this documented? I mean how BaseX deals with the third
argument? I couldn't find it. The spec leaves it open to
implementations.

--Marc

On Thu, Aug 13, 2015 at 3:37 PM, Dirk Kirsten d...@basex.org wrote:
 Hi Marc,

 I agree, I think 500 would be more in line with the HTTP status code
 definitions.. It wasn't really an issue for us in our commercial projects
 ever (as we mostly send custom status code) and I guess this is why no one
 cared/noticed, but it would be cleaner to use 500 by default. By the way,
 you can define the status code easily by using  the third argument of the
 error function:

 fn:error( xs:QName('error'), message, 500)

 However, as it would be a breaking change it might be wise to delay the
 switch until BaseX 9. Or, of course, there are indeed some reasons why this
 is 400.

 Cheers
 Dirk

 On 08/13/2015 03:06 PM, Marc van Grootel wrote:

 Hi,

 Nothing major but I was wondering what the thinking was behind
 returning a 400 when fn:error is raised. Basically that says client,
 your mistake not mine where in most cases I guess a 500 would be more
 appropriate.

 Where is this decided (RESTXQ?) and is there an easy way to change the
 status when fn:error is used?

 Of course I can always catch at the highest level and then decide
 which HTTP status to return but I'm not sure if I want to wrap all
 REST calls in try / catch.


 --
 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



-- 
--Marc


Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Yes, I think it's a CACHERESTXQ bug. The handler I posted earlier
triggers it. Not sure what exactly triggers it.

Yes, if only we had a time machine. Kidding aside, REST
services/microservices/UI clients/Javascript frameworks all are
pushing on REST. I was triggered by recent developments by
Facebook/Netflix and recently summarized in a talk on InfoQ called
Demand Driven architecture
(https://qconnewyork.com/ny2015/presentation/demand-driven-architecture).
I think that it solves issues for UI clients. I'm looking into which
forum to raise the issue or if I should just do the pragmatic thing,
use POST, and shut up. I'm a bit scared for religuous fanatism.  ;-)



On Tue, Aug 4, 2015 at 12:01 PM, Christian Grün
christian.gr...@gmail.com wrote:
 I figured it out. The way to repro is with the function I posted
 earlier. Start the server but with CACHERESTXQ=true. Test the
 function: works fine. Change the handler function/file and save it.
 Retry the POST,  boom. NPE. Switching CACHERESTXQ=false no fixes this.

 I see; so it seems to be  a CACHERESTXQ bug, right? (Andy: thanks as well).

 Maybe I get crucified for saying this but I think we should
 allow GET with body.

 Maybe even Roy agrees with you today, but we should probably have
 intervened and fixed that 20 years ago ;) We could obviously weaken
 the RESTXQ constraints, but it may be advisable to first check out if
 there has been a similar discussion on JAX-RS.



  And yes, it's very useful and can simplify
 clients that need to specify complex queries to a REST server. I stop
 ranting now, I probably should take this somewhere else but I'm still
 building up courage to do so ;-)



 On Tue, Aug 4, 2015 at 11:05 AM, Christian Grün
 christian.gr...@gmail.com wrote:
 All existing test cases seem to work, and I didn't come across this in
 my simple queries. Could you please provide me with a function and
 call that triggers the exception?


 On Tue, Aug 4, 2015 at 11:00 AM, Marc van Grootel
 marc.van.groo...@gmail.com wrote:
 I've double checked the version and manually downloaded latest. I'm
 now on BaseX 8.3 beta e13a5f0 which I assume is correct.

 Not sure what's going on but in most cases (with format=map) gives me
 a NPE (and {foo: bar}):

 Unexpected error: Improper use? Potential bug? Your feedback is welcome:
 Contact: basex-talk@mailman.uni-konstanz.de
 Version: BaseX 8.3 beta e13a5f0
 Java: Oracle Corporation, 1.7.0_25
 OS: Windows 7, amd64
 Stack Trace:
 java.lang.NullPointerException
 at org.basex.http.restxq.RestXqFunction.parse(RestXqFunction.java:124)
 at org.basex.http.restxq.RestXqModule.process(RestXqModule.java:100)
 at org.basex.http.restxq.RestXqFunction.process(RestXqFunction.java:109)
 at org.basex.http.restxq.RestXqServlet.run(RestXqServlet.java:44)
 at org.basex.http.BaseXServlet.service(BaseXServlet.java:64)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
 at 
 org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
 at 
 org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
 at 
 org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
 at 
 org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
 at 
 org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
 at 
 org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
 at 
 org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
 at 
 org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
 at 
 org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
 at 
 org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
 at org.eclipse.jetty.server.Server.handle(Server.java:370)
 at 
 org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
 at 
 org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)
 at 
 org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)
 at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
 at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
 at 
 org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
 at 
 org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
 at 
 org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
 at 
 org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
 at 
 org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
 at java.lang.Thread.run(Thread.java:724)



 On Tue, Aug 4, 2015 at 10:48 AM, Marc van Grootel
 marc.van.groo...@gmail.com wrote:
 Hi Christian,

 I pulled it via the Maven repo using Gradle. It says BaseX 8.3 beta

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Hi Christian,

Super-fast as always ;-)

I'm still struggling though. Couple of points

I have this RESTXQ function that I'm trying to get working.


declare %rest:POST({$query}) %rest:path(/json)
%rest:consumes(application/json)
%rest:produces(application/json)
%input:json(format=map)
function api:json($query)
{
$query
};

I'm posting this as the body (and have Content-Type=application/json)

{foo: bar}

I can get this to work with %input:json format=direct/format=basic but
when I change to format=map I still get

[bxerr:BASX0003] Input could not be converted: POST.xml (Line 1): No
text allowed before root element.

What I want to achieve is not go through JSON  XML parsing but get
the same effect as using fn:parse-json() on the incoming JSON and
fn:serialize(..., map { 'method': JSON }) on the output.

I can imagine it's the RESTXQ layer itself that preps the args that
insists on turning the JSON into XML. Maybe because it hasn't been
revamped to fit XQuery 3.1 where we can have native arrays and maps.

A second point regarding format=map. Not sure if this is the correct
name as I could be posting [1,2,3] which is valid JSON. Does this
mean there should be a format=array or would it be better to give a
different name for this format.

--Marc

On Mon, Aug 3, 2015 at 6:47 PM, Christian Grün
christian.gr...@gmail.com wrote:
 …fixed, and available via the latest snapshot [1].

 Thanks,
 Christian

 [1] http://files.basex.org/releases/latest



 On Mon, Aug 3, 2015 at 5:11 PM, Christian Grün
 christian.gr...@gmail.com wrote:
 Hi Marc,

 I'm using Postman. I already had Content-Type = application/json and
 Accept = application/json.
 I tried changing it to application/json;format=map

 I noticed that you get different result when specify 'format=basic' or
 'format=direct':

   curl  -XPUT
 -HContent-Type:application/json;format=basic
 -Tinput.json http://localhost:8984/test;

 ..so I guess something is going wrong here. I'll dive into this soon.

 (btw do you think it's necessary to have the basex/restxq specific
 pseudo attributes (format= etc) in the HTTP request headers?)

 You can also use %input:json(...) if you don't want to specify the
 format client-side.

 Maybe something to forward to Adam Retter / RESTXQ?

 So far, the content-type parameter extensions have not been adopted in
 RESTXQ yet, but feel free to give him an update!

 Christian



-- 
--Marc


Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
A last point I would like to make is that I still find it dubious that
the client can specify things in a header (Content Type) that override
the way it's porcessed on the server. Isn't this a case of The server
knows best. As a client I just specify that this is JSON and leave it
up to the server how to process. If I do that and put an
%input:json(...) annotation on the RESTXQ handler it can still be
overridden by things specified in the header by the client.
But again this probably should be directed at RESTXQ rather than BaseX.

--Marc


On Tue, Aug 4, 2015 at 10:01 AM, Marc van Grootel
marc.van.groo...@gmail.com wrote:
 Hi Christian,

 Super-fast as always ;-)

 I'm still struggling though. Couple of points

 I have this RESTXQ function that I'm trying to get working.


 declare %rest:POST({$query}) %rest:path(/json)
 %rest:consumes(application/json)
 %rest:produces(application/json)
 %input:json(format=map)
 function api:json($query)
 {
 $query
 };

 I'm posting this as the body (and have Content-Type=application/json)

 {foo: bar}

 I can get this to work with %input:json format=direct/format=basic but
 when I change to format=map I still get

 [bxerr:BASX0003] Input could not be converted: POST.xml (Line 1): No
 text allowed before root element.

 What I want to achieve is not go through JSON  XML parsing but get
 the same effect as using fn:parse-json() on the incoming JSON and
 fn:serialize(..., map { 'method': JSON }) on the output.

 I can imagine it's the RESTXQ layer itself that preps the args that
 insists on turning the JSON into XML. Maybe because it hasn't been
 revamped to fit XQuery 3.1 where we can have native arrays and maps.

 A second point regarding format=map. Not sure if this is the correct
 name as I could be posting [1,2,3] which is valid JSON. Does this
 mean there should be a format=array or would it be better to give a
 different name for this format.

 --Marc

 On Mon, Aug 3, 2015 at 6:47 PM, Christian Grün
 christian.gr...@gmail.com wrote:
 …fixed, and available via the latest snapshot [1].

 Thanks,
 Christian

 [1] http://files.basex.org/releases/latest



 On Mon, Aug 3, 2015 at 5:11 PM, Christian Grün
 christian.gr...@gmail.com wrote:
 Hi Marc,

 I'm using Postman. I already had Content-Type = application/json and
 Accept = application/json.
 I tried changing it to application/json;format=map

 I noticed that you get different result when specify 'format=basic' or
 'format=direct':

   curl  -XPUT
 -HContent-Type:application/json;format=basic
 -Tinput.json http://localhost:8984/test;

 ..so I guess something is going wrong here. I'll dive into this soon.

 (btw do you think it's necessary to have the basex/restxq specific
 pseudo attributes (format= etc) in the HTTP request headers?)

 You can also use %input:json(...) if you don't want to specify the
 format client-side.

 Maybe something to forward to Adam Retter / RESTXQ?

 So far, the content-type parameter extensions have not been adopted in
 RESTXQ yet, but feel free to give him an update!

 Christian



 --
 --Marc



-- 
--Marc


Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
I got it working using this function. One requirement though is that
the client must send the JSON with a text content type or no
content-type. This way the function receives a string argument and I
can do with the string what I want.
Not 100% satisfied because the client has to lie about it's content
type in order to get this to work.

declare %rest:POST({$query}) %rest:path(/json)
%rest:produces(application/json)
function api:json($query)
{
rest:response
output:serialization-parameters
output:media-type value=application/json/
/output:serialization-parameters
/rest:response,
serialize(parse-json($query), map { 'method': 'json'})
};

BTW some background: I'm trying to implement a pattern for sending
query specification via REST (this allows a much better query language
instead of forcing everything through query params). Elastic Search
does this too. My first instinct was to use a body with GET but,
although the HTTP specs more or less allow it many tools and libraries
(including BaseX/RESTXQ) do not support sending bodies with GET. So
now I'm doing this with POST which feels wrong too.

--Marc


On Tue, Aug 4, 2015 at 10:16 AM, Marc van Grootel
marc.van.groo...@gmail.com wrote:
 A last point I would like to make is that I still find it dubious that
 the client can specify things in a header (Content Type) that override
 the way it's porcessed on the server. Isn't this a case of The server
 knows best. As a client I just specify that this is JSON and leave it
 up to the server how to process. If I do that and put an
 %input:json(...) annotation on the RESTXQ handler it can still be
 overridden by things specified in the header by the client.
 But again this probably should be directed at RESTXQ rather than BaseX.

 --Marc


 On Tue, Aug 4, 2015 at 10:01 AM, Marc van Grootel
 marc.van.groo...@gmail.com wrote:
 Hi Christian,

 Super-fast as always ;-)

 I'm still struggling though. Couple of points

 I have this RESTXQ function that I'm trying to get working.


 declare %rest:POST({$query}) %rest:path(/json)
 %rest:consumes(application/json)
 %rest:produces(application/json)
 %input:json(format=map)
 function api:json($query)
 {
 $query
 };

 I'm posting this as the body (and have Content-Type=application/json)

 {foo: bar}

 I can get this to work with %input:json format=direct/format=basic but
 when I change to format=map I still get

 [bxerr:BASX0003] Input could not be converted: POST.xml (Line 1): No
 text allowed before root element.

 What I want to achieve is not go through JSON  XML parsing but get
 the same effect as using fn:parse-json() on the incoming JSON and
 fn:serialize(..., map { 'method': JSON }) on the output.

 I can imagine it's the RESTXQ layer itself that preps the args that
 insists on turning the JSON into XML. Maybe because it hasn't been
 revamped to fit XQuery 3.1 where we can have native arrays and maps.

 A second point regarding format=map. Not sure if this is the correct
 name as I could be posting [1,2,3] which is valid JSON. Does this
 mean there should be a format=array or would it be better to give a
 different name for this format.

 --Marc

 On Mon, Aug 3, 2015 at 6:47 PM, Christian Grün
 christian.gr...@gmail.com wrote:
 …fixed, and available via the latest snapshot [1].

 Thanks,
 Christian

 [1] http://files.basex.org/releases/latest



 On Mon, Aug 3, 2015 at 5:11 PM, Christian Grün
 christian.gr...@gmail.com wrote:
 Hi Marc,

 I'm using Postman. I already had Content-Type = application/json and
 Accept = application/json.
 I tried changing it to application/json;format=map

 I noticed that you get different result when specify 'format=basic' or
 'format=direct':

   curl  -XPUT
 -HContent-Type:application/json;format=basic
 -Tinput.json http://localhost:8984/test;

 ..so I guess something is going wrong here. I'll dive into this soon.

 (btw do you think it's necessary to have the basex/restxq specific
 pseudo attributes (format= etc) in the HTTP request headers?)

 You can also use %input:json(...) if you don't want to specify the
 format client-side.

 Maybe something to forward to Adam Retter / RESTXQ?

 So far, the content-type parameter extensions have not been adopted in
 RESTXQ yet, but feel free to give him an update!

 Christian



 --
 --Marc



 --
 --Marc



-- 
--Marc


Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Hi Christian,

I pulled it via the Maven repo using Gradle. It says BaseX 8.3 beta 7f8299f.
Maybe that doesn't carry the latest?

Re format name suggestions: format=item (not good, includes XML
nodes), format=function (correct per
http://www.w3.org/TR/xpath-datamodel-31/#types-representation as it
includes array and map) but confusing. format=native (maybe?)

I agree fully that the server should have the last say in how to
process the content so I would definitely be in favor of prioritizing
server parameters. Not sure if that breaks something out there though.

--Marc



On Tue, Aug 4, 2015 at 10:31 AM, Christian Grün
christian.gr...@gmail.com wrote:
 Hi Marc,

 I can get this to work with %input:json format=direct/format=basic but
 when I change to format=map I still get

 [bxerr:BASX0003] Input could not be converted: POST.xml (Line 1): No
 text allowed before root element.

 Hm, it seems to work on my machine. Here is again the minimized
 version (I also tried the function you sent to me; I removed the
 %rest:consumes and %rest:produces annotations, because they only serve
 as filters, and do not influence the conversion of $query):

 declare %rest:POST({$query}) %rest:path(/json)
 function local:json($query) {
   $query
 };

 curl -XPOST -HContent-Type:application/json;format=map
   -Tinput.json http://localhost:8984/json;

 Are you sure you tried the latest snapshot?

 A second point regarding format=map. Not sure if this is the correct
 name as I could be posting [1,2,3] which is valid JSON. Does this
 mean there should be a format=array or would it be better to give a
 different name for this format.

 This is a valid point. It stems from the beginnings of that feature,
 where the top object was always a map. Do you possibly have a
 suggestion for a better name?

 A last point I would like to make is that I still find it dubious that
 the client can specify things in a header (Content Type) that override
 the way it's porcessed on the server.

 I think it's basically a good idea to allow a client to specify
 content-type parameters. But it's true that the server parameter
 should probably be priorized and overwrite a client parameter, instead
 of the other way round. Do you agree?

 Christian



-- 
--Marc


Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Thanks, came to that conclusion too, strange things is that
CACHERESTXQ=true never bit me before. First time I have issues with
it. I have it set to true almost all the time.

--Marc

On Tue, Aug 4, 2015 at 11:24 AM, Andy Bunce bunce.a...@gmail.com wrote:
 This looks a bit like errors I have seen with CACHERESTXQ=true [1]
 and then hot swapping the XQuery files. Requesting  /.init sorts it for me.
 /Andy
 [1] http://docs.basex.org/wiki/Options#CACHERESTXQ

 On 4 August 2015 at 10:05, Christian Grün christian.gr...@gmail.com wrote:

 All existing test cases seem to work, and I didn't come across this in
 my simple queries. Could you please provide me with a function and
 call that triggers the exception?


 On Tue, Aug 4, 2015 at 11:00 AM, Marc van Grootel
 marc.van.groo...@gmail.com wrote:
  I've double checked the version and manually downloaded latest. I'm
  now on BaseX 8.3 beta e13a5f0 which I assume is correct.
 
  Not sure what's going on but in most cases (with format=map) gives me
  a NPE (and {foo: bar}):
 
  Unexpected error: Improper use? Potential bug? Your feedback is welcome:
  Contact: basex-talk@mailman.uni-konstanz.de
  Version: BaseX 8.3 beta e13a5f0
  Java: Oracle Corporation, 1.7.0_25
  OS: Windows 7, amd64
  Stack Trace:
  java.lang.NullPointerException
  at org.basex.http.restxq.RestXqFunction.parse(RestXqFunction.java:124)
  at org.basex.http.restxq.RestXqModule.process(RestXqModule.java:100)
  at org.basex.http.restxq.RestXqFunction.process(RestXqFunction.java:109)
  at org.basex.http.restxq.RestXqServlet.run(RestXqServlet.java:44)
  at org.basex.http.BaseXServlet.service(BaseXServlet.java:64)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
  at
  org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
  at
  org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
  at
  org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
  at
  org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
  at
  org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
  at
  org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
  at
  org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
  at
  org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
  at
  org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
  at
  org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
  at
  org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
  at org.eclipse.jetty.server.Server.handle(Server.java:370)
  at
  org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
  at
  org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)
  at
  org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)
  at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
  at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
  at
  org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
  at
  org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
  at
  org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
  at
  org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
  at
  org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
  at java.lang.Thread.run(Thread.java:724)
 
 
 
  On Tue, Aug 4, 2015 at 10:48 AM, Marc van Grootel
  marc.van.groo...@gmail.com wrote:
  Hi Christian,
 
  I pulled it via the Maven repo using Gradle. It says BaseX 8.3 beta
  7f8299f.
  Maybe that doesn't carry the latest?
 
  Re format name suggestions: format=item (not good, includes XML
  nodes), format=function (correct per
  http://www.w3.org/TR/xpath-datamodel-31/#types-representation as it
  includes array and map) but confusing. format=native (maybe?)
 
  I agree fully that the server should have the last say in how to
  process the content so I would definitely be in favor of prioritizing
  server parameters. Not sure if that breaks something out there though.
 
  --Marc
 
 
 
  On Tue, Aug 4, 2015 at 10:31 AM, Christian Grün
  christian.gr...@gmail.com wrote:
  Hi Marc,
 
  I can get this to work with %input:json format=direct/format=basic
  but
  when I change to format=map I still get
 
  [bxerr:BASX0003] Input could not be converted: POST.xml (Line 1):
  No
  text allowed before root element.
 
  Hm, it seems to work on my machine. Here is again the minimized
  version (I also tried the function you sent to me; I removed the
  %rest:consumes and %rest:produces annotations, because they only serve
  as filters, and do not influence the conversion of $query):
 
  declare %rest:POST({$query}) %rest:path

Re: [basex-talk] Round tripping JSON

2015-08-04 Thread Marc van Grootel
Hi Christian,

I figured it out. The way to repro is with the function I posted
earlier. Start the server but with CACHERESTXQ=true. Test the
function: works fine. Change the handler function/file and save it.
Retry the POST,  boom. NPE. Switching CACHERESTXQ=false no fixes this.

About the conversion. I'm fine with the default being parse into XML
as long as i can fix it to parse as array/map using a handler
annotation (and in a way that the client cannot mess with this). No
need to change defaults.

Maybe the wrong forum here but that REST discussion:

   Server semantics for GET, however, are restricted such that a body,
   if any, has no semantic meaning to the request. The requirements
   on parsing are separate from the requirements on method semantics.

What is that supposed to mean (pun intended)? If with semantics they
mean HTTP verb semantics. Eg. GET is idempotent etc. then my use case
where the body is simply an easier way to specify a query to the
server and thus fully compatible with GET semantics. I see no
difference with providing params via the URL string or path. Somehow
in the past somebody (not sure if it was Fielding himself, maybe the
people from the HTTP spec) decided body should not be part of a GET
and all that needs to be done with GET semantics can be done with
query strings. Now I'm forced to use POST which HTTP semantics are
create a new resource. To me this seems worse then using GET and most
implementers have chosen to conflate specs with morals (the REST
morals). I already found out that going for GET is useless as the road
is riddled with tools and libraries that forbid you from doing so. And
also ES had to allow the same queries to be POSTed instead of provided
with GET. Maybe I get crucified for saying this but I think we should
allow GET with body. And yes, it's very useful and can simplify
clients that need to specify complex queries to a REST server. I stop
ranting now, I probably should take this somewhere else but I'm still
building up courage to do so ;-)



On Tue, Aug 4, 2015 at 11:05 AM, Christian Grün
christian.gr...@gmail.com wrote:
 All existing test cases seem to work, and I didn't come across this in
 my simple queries. Could you please provide me with a function and
 call that triggers the exception?


 On Tue, Aug 4, 2015 at 11:00 AM, Marc van Grootel
 marc.van.groo...@gmail.com wrote:
 I've double checked the version and manually downloaded latest. I'm
 now on BaseX 8.3 beta e13a5f0 which I assume is correct.

 Not sure what's going on but in most cases (with format=map) gives me
 a NPE (and {foo: bar}):

 Unexpected error: Improper use? Potential bug? Your feedback is welcome:
 Contact: basex-talk@mailman.uni-konstanz.de
 Version: BaseX 8.3 beta e13a5f0
 Java: Oracle Corporation, 1.7.0_25
 OS: Windows 7, amd64
 Stack Trace:
 java.lang.NullPointerException
 at org.basex.http.restxq.RestXqFunction.parse(RestXqFunction.java:124)
 at org.basex.http.restxq.RestXqModule.process(RestXqModule.java:100)
 at org.basex.http.restxq.RestXqFunction.process(RestXqFunction.java:109)
 at org.basex.http.restxq.RestXqServlet.run(RestXqServlet.java:44)
 at org.basex.http.BaseXServlet.service(BaseXServlet.java:64)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
 at 
 org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
 at 
 org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
 at 
 org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
 at 
 org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
 at 
 org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
 at 
 org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
 at 
 org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
 at 
 org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
 at org.eclipse.jetty.server.Server.handle(Server.java:370)
 at 
 org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
 at 
 org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)
 at 
 org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)
 at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
 at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
 at 
 org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
 at 
 org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
 at 
 org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53

Re: [basex-talk] Round tripping JSON

2015-08-03 Thread Marc van Grootel
Hi Christian,

No luck.

I'm using Postman. I already had Content-Type = application/json and
Accept = application/json.
I tried changing it to application/json;format=map
(btw do you think it's necessary to have the basex/restxq specific
pseudo attributes (format= etc) in the HTTP request headers?)

I'm seeing 400 errors like this:

[bxerr:BASX0003] Input could not be converted: POST.xml (Line 1): No
text allowed before root element.


So something is different now but still there seems to be an
expectation somewhere on the post being XML at least the filename
suggests so.

The documentation is a bit contradictory:

The body of a POST or PUT request will be converted to an XQuery
item. Conversion can be controlled by specifying a content type.
 It can be further influenced by specifying additional
content-type parameters:

The table below lists:


application/jsonJSON Optionsdocument-node()

On Mon, Aug 3, 2015 at 4:42 PM, Christian Grün
christian.gr...@gmail.com wrote:
 Hi Marc,

 declare %rest:POST({$body}) %rest:path(/json)
 %rest:consumes(application/json;lax=yes;format=map)
 %rest:produces(application/json;format=map)

 If I remember right, content-type parameters in rest annotations will
 be ignored, because these annotations only serve as filters. Instead,
 you will need to specify the content-type parameters client-side (in
 your POST or PUT request).

 Hope this helps,
 Christian



-- 
--Marc


Re: [basex-talk] Destination of result-document from XSLT module

2015-08-03 Thread Marc

Thank Vincent,
But it the input of the xslt I want to control.
I'm using BaseX with the CHOP false because I use text documentation and space 
is important at the end or the begining of an element, and when I try to use 
xslt (with baseX 7) it serialize with indent true the input of my xslt, so I 
lost the space.
Marc
Le 03/08/2015 23:07, Lizzi, Vincent a écrit :

Thanks, Max and Andy. The XQuery 3.1 transform function looks promising.

Marc, For controlling the serialization of XSLT output, you can specify 
serialization for the XSLT within the XSLT itself using xsl:output, run the 
XSLT using the xslt:transform-text, and then write the output to a file.

file:write-text('file.txt', xslt:transform-text($doc, $xslt))

I'm not sure if this will do what you need, but so far it has been working for 
me.

Vincent



-Original Message-
From: basex-talk-boun...@mailman.uni-konstanz.de 
[mailto:basex-talk-boun...@mailman.uni-konstanz.de] On Behalf Of Marc
Sent: Monday, August 03, 2015 4:53 PM
Cc: basex-talk@mailman.uni-konstanz.de
Subject: Re: [basex-talk] Destination of result-document from XSLT module

Hi,
I have an other problem is to control the serialization of the node passed to 
the transform function.
I don't see how to control it.
Marc
Le 03/08/2015 22:32, Andy Bunce a écrit :
 Hi Max,
 This sounds like a good thing.
 Another solution to the result-document issue might be to implement
 the XQuery 3.1 transform function [1]

 /Andy
 [1] http://www.w3.org/TR/xpath-functions-31/#func-transform

 On 3 August 2015 at 20:54, Max Goltzsche max.goltzs...@algorythm.de
 mailto:max.goltzs...@algorythm.de wrote:

  Hello Vincent,

  besides an URI resolver I also want to set XSLT 2.0's output
  destination in BaseX.
  Currently as you can see in BaseX' xslt:transform and
  xslt:transform-text implementation in
  
https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/func/xslt/XsltTransform.java
  there is neither an URIResolver or OutputURIResolver set on the
  Transformer nor a destination systemId set on its StreamResult. Thus
  Saxon resolves output paths relative to your Java process' working
  directory (in fact all relative XSL include, import, document and
  collection paths in the XSLT passed to the transform method).
  Unfortunately to change this behaviour the XsltTransform class must
  be enhanced.
  If you need a quicker* solution for your problem you may have to
  build your own BaseX transform Java Module based on the
  XsltTransform class setting at least the StreamResult's systemId I
  think.
  I will be also working on this the next evenings.

  best regards,
  Max


  On 03.08.2015 20:54, Lizzi, Vincent wrote:

  I’m trying to use the XSLT Module in BaseX 8.2.3 with Saxon 9.6 to
  run an XSLT that produces several output documents using
  xsl:result-document. I’m having trouble setting the location of
  the output documents. I want to have xsl:result-document create
  the output documents in a temporary folder because the documents
  need to be zipped together. 

  __ __

  According to Saxon’s documentation, the a relative path in the
  href attribute of xsl:result-document will be resolved using
  either the path of the Destination, or the current directory. The
  XSLT Module does not appear have a way to provide a path for a
  destination document.  What I’m seeing is that the result
  documents are created in BaseX’s home directory. The XSLT works as
  expected when run using Saxon from the command line, where it’s
  possible to set a destination path.

  __ __

  Is there a way to specify a Base Output URI to the XSLT Module?
  Or, would it be possible to specify a file URI output location to
  a method like xslt:transform?

  __ __

  One possible workaround is to provide an absolute path as a
  parameter to the XSLT, and use that parameter in the
  xsl:result-document href location. 

  __ __

  Here is a self-contained example code:

  __ __

  __ __

  declare function local:example($in, $xsl, $zipPath) {

let $tempDir := file:create-temp-dir('test', 'example')

let $x := xslt:transform-text($in, $xsl)

return 

  let $zip := archive:create-from($tempDir)

  return (

  file:write-binary($zipPath, $zip)

(: , file:delete($tempDir, true()) :)

  )

  };

  __ __

  __ __

  let $xsl := xsl:stylesheet
  xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
  http://www.w3.org/1999/XSL/Transform
  xmlns:xs=http://www.w3.org/2001/XMLSchema;
  http://www.w3.org/2001/XMLSchema version=2.0

  xsl:template match=/

  xsl:result-document href=doc1.xml

  testthis

Re: [basex-talk] Round tripping JSON

2015-08-03 Thread Marc van Grootel
Wow, clicked send before I meant to.
The last line was a copy from the table in the documentation and the
last column has document-node() which seems to suggest that getting
a map(*) there isn't possible. So not sure what is supposed to happen.

Anyway I would think that correct behaviour would be, I think, to
deliver a map(*) to the function  instead of a document-node() in this
case.

Maybe something to forward to Adam Retter / RESTXQ?

--Marc

On Mon, Aug 3, 2015 at 4:54 PM, Marc van Grootel
marc.van.groo...@gmail.com wrote:
 Hi Christian,

 No luck.

 I'm using Postman. I already had Content-Type = application/json and
 Accept = application/json.
 I tried changing it to application/json;format=map
 (btw do you think it's necessary to have the basex/restxq specific
 pseudo attributes (format= etc) in the HTTP request headers?)

 I'm seeing 400 errors like this:

 [bxerr:BASX0003] Input could not be converted: POST.xml (Line 1): No
 text allowed before root element.


 So something is different now but still there seems to be an
 expectation somewhere on the post being XML at least the filename
 suggests so.

 The documentation is a bit contradictory:

 The body of a POST or PUT request will be converted to an XQuery
 item. Conversion can be controlled by specifying a content type.
  It can be further influenced by specifying additional
 content-type parameters:

 The table below lists:


 application/jsonJSON Optionsdocument-node()

 On Mon, Aug 3, 2015 at 4:42 PM, Christian Grün
 christian.gr...@gmail.com wrote:
 Hi Marc,

 declare %rest:POST({$body}) %rest:path(/json)
 %rest:consumes(application/json;lax=yes;format=map)
 %rest:produces(application/json;format=map)

 If I remember right, content-type parameters in rest annotations will
 be ignored, because these annotations only serve as filters. Instead,
 you will need to specify the content-type parameters client-side (in
 your POST or PUT request).

 Hope this helps,
 Christian



 --
 --Marc



-- 
--Marc


Re: [basex-talk] Destination of result-document from XSLT module

2015-08-03 Thread Marc

Hi,
I have an other problem is to control the serialization of the node passed to 
the transform function.
I don't see how to control it.
Marc
Le 03/08/2015 22:32, Andy Bunce a écrit :

Hi Max,
This sounds like a good thing.
Another solution to the result-document issue might be to implement the
XQuery 3.1 transform function [1]

/Andy
[1] http://www.w3.org/TR/xpath-functions-31/#func-transform

On 3 August 2015 at 20:54, Max Goltzsche max.goltzs...@algorythm.de
mailto:max.goltzs...@algorythm.de wrote:

Hello Vincent,

besides an URI resolver I also want to set XSLT 2.0's output
destination in BaseX.
Currently as you can see in BaseX' xslt:transform and
xslt:transform-text implementation in

https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/func/xslt/XsltTransform.java
there is neither an URIResolver or OutputURIResolver set on the
Transformer nor a destination systemId set on its StreamResult. Thus
Saxon resolves output paths relative to your Java process' working
directory (in fact all relative XSL include, import, document and
collection paths in the XSLT passed to the transform method).
Unfortunately to change this behaviour the XsltTransform class must
be enhanced.
If you need a quicker* solution for your problem you may have to
build your own BaseX transform Java Module based on the
XsltTransform class setting at least the StreamResult's systemId I
think.
I will be also working on this the next evenings.

best regards,
Max


On 03.08.2015 20:54, Lizzi, Vincent wrote:

 I’m trying to use the XSLT Module in BaseX 8.2.3 with Saxon 9.6 to
 run an XSLT that produces several output documents using
 xsl:result-document. I’m having trouble setting the location of
 the output documents. I want to have xsl:result-document create
 the output documents in a temporary folder because the documents
 need to be zipped together. 

 __ __

 According to Saxon’s documentation, the a relative path in the
 href attribute of xsl:result-document will be resolved using
 either the path of the Destination, or the current directory. The
 XSLT Module does not appear have a way to provide a path for a
 destination document.  What I’m seeing is that the result
 documents are created in BaseX’s home directory. The XSLT works as
 expected when run using Saxon from the command line, where it’s
 possible to set a destination path.

 __ __

 Is there a way to specify a Base Output URI to the XSLT Module?
 Or, would it be possible to specify a file URI output location to
 a method like xslt:transform?

 __ __

 One possible workaround is to provide an absolute path as a
 parameter to the XSLT, and use that parameter in the
 xsl:result-document href location. 

 __ __

 Here is a self-contained example code:

 __ __

 __ __

 declare function local:example($in, $xsl, $zipPath) {

   let $tempDir := file:create-temp-dir('test', 'example')

   let $x := xslt:transform-text($in, $xsl)

   return 

 let $zip := archive:create-from($tempDir)

 return (

 file:write-binary($zipPath, $zip)

   (: , file:delete($tempDir, true()) :)

 )

 };

 __ __

 __ __

 let $xsl := xsl:stylesheet
 xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
 http://www.w3.org/1999/XSL/Transform
 xmlns:xs=http://www.w3.org/2001/XMLSchema;
 http://www.w3.org/2001/XMLSchema version=2.0

 xsl:template match=/

 xsl:result-document href=doc1.xml

 testthis is a test 1 xsl:apply-templates//test

 /xsl:result-document

 xsl:result-document href=doc2.xml

 testthis is a test 2 xsl:apply-templates//test

 /xsl:result-document

 /xsl:template

 /xsl:stylesheet

 __ __

 let $doc := testthis is input/test

 __ __

 let $zipPath := 'report.zip'

 __ __

 return local:example($doc, $xsl, $zipPath)

 __ __

 The expected output is a zip file report.zip that contains
 doc1.xml and doc2.xml. 

 __ __

 However, what I’m seeing is that report.zip is created as an empty
 zip file and doc1.xml and doc2.xml are placed in BaseX’s home
 directory.

 __ __

 Thanks,

 Vincent





Re: [basex-talk] Union of maps?

2015-07-15 Thread Marc van Grootel
Hi Graydon, have a look here 
https://github.com/xokomola/fold/blob/dbb79c60a7356e32a0994e581ad4f7f5377ddc72/webapp/fold-common/common.xqm#L125

hope it helps

--Marc

 On 15 jul. 2015, at 20:01, Graydon Saunders graydon...@gmail.com wrote:
 
 Hi --
 
 In BaseX 8.2.1, I have a bunch of maps; the maps may have some overlap of key 
 values.  I would like to merge/find the union of all of these maps while 
 retaining all the values associated with each key in the resulting 
 map-of-all-maps.  (Combined map?  Any word can be wrong, here! :)
 
 map:merge() doesn't do this;  http://docs.basex.org/wiki/Map_Module#map:merge 
 says
 The associated value for each such key is taken from the last map in the 
 input sequence $input that contains an entry with this key. and testing 
 confirms this.
 
 Is there a straightforward way to do this that I'm missing?
 
 Thanks!
 Graydon


Re: [basex-talk] Union of maps?

2015-07-15 Thread Marc van Grootel
Looking at that code again I think it should be rewritten to use map:for-each
it's too convoluted, but it probably gives you an idea of how to proceed.
Here's a test that shows how it works.
https://github.com/xokomola/fold/blob/dbb79c60a7356e32a0994e581ad4f7f5377ddc72/test/fold-common/test-common.xqm#L166
--Marc

 On 15 jul. 2015, at 21:51, Marc van Grootel marc.van.groo...@gmail.com 
 wrote:
 
 Hi Graydon, have a look here 
 https://github.com/xokomola/fold/blob/dbb79c60a7356e32a0994e581ad4f7f5377ddc72/webapp/fold-common/common.xqm#L125
 
 hope it helps
 
 --Marc
 
 On 15 jul. 2015, at 20:01, Graydon Saunders graydon...@gmail.com wrote:
 
 Hi --
 
 In BaseX 8.2.1, I have a bunch of maps; the maps may have some overlap of 
 key values.  I would like to merge/find the union of all of these maps while 
 retaining all the values associated with each key in the resulting 
 map-of-all-maps.  (Combined map?  Any word can be wrong, here! :)
 
 map:merge() doesn't do this;  
 http://docs.basex.org/wiki/Map_Module#map:merge says
 The associated value for each such key is taken from the last map in the 
 input sequence $input that contains an entry with this key. and testing 
 confirms this.
 
 Is there a straightforward way to do this that I'm missing?
 
 Thanks!
 Graydon


Re: [basex-talk] Whitespace

2015-07-14 Thread Marc
Hi
You can use the serialisation parameter with no indent option. 
Marc

On July 14, 2015 8:13:09 PM CEST, meumapple meumap...@gmail.com wrote:
Hi,

When I use the file:write function, the whitespaces before an element
are deleted (and also the initial whitespace of a string in an
element). This is a problem for elements containing text and elements.
Is there a way to avoid this? Thanks.

J.

-- 
Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.

Re: [basex-talk] Basex Standalone : [bxerr:BXSQ0007] Could not initialize supplied driver: 'com.mysql.jdbc.Driver'

2015-05-12 Thread jean-marc Mercier
Christian,

Hello. Thx for your answer. I've tried your suggestion, but I can't set the
Java Build path using Eclipse/ Project / Properties (my IDE is eclipse
together with BaseX Interpreter) :
[image: Images intégrées 1]
This is a minor issue : I can survive using the BaseX server. It is only
hardening dev / debug, since I don't know how to trace using BAseX server
(fn:trace seems not to output anything using the basex server, maybe I
missed something here ?).

Cheers


2015-05-11 22:05 GMT+02:00 Christian Grün christian.gr...@gmail.com:

 Hi Jean-Marc,

  I guess that it might be due to the fact that I don't know how to include
  multiple jar while using with eclipse. I tried to go to
  Windows/Preferences/XQUERY/Interpreters and set -classpath
  {BaseXDirectory}\lib\*, but it does not work.

 You will probably have to include the libraries as follows:

   Project → Properties → Java Build Path →
   Libraries → Add JARs...

 Hope this helps,
 Christian



 
  Maybe somebody already met this small issue before ?
 
  Thanks for your answer,
 
  cheers



[basex-talk] Basex Standalone : [bxerr:BXSQ0007] Could not initialize supplied driver: 'com.mysql.jdbc.Driver'

2015-05-11 Thread jean-marc Mercier
Hi,

I am struggling to use Basex sql module together with Basex Standalone. I
am getting the error  : [bxerr:BXSQ0007] Could not initialize supplied
driver: 'com.mysql.jdbc.Driver'

The sql connection works finely while using the Basex server.

I guess that it might be due to the fact that I don't know how to include
multiple jar while using with eclipse. I tried to go to
Windows/Preferences/XQUERY/Interpreters and set -classpath
{BaseXDirectory}\lib\*, but it does not work.

Maybe somebody already met this small issue before ?

Thanks for your answer,

cheers


[basex-talk] RESTXQ accept/produces issue

2015-04-21 Thread Marc van Grootel
Hi,

I spend a couple of hours pulling my hair before I realized what was
going on here.

Question: what happens when I call a RESTXQ function which has a
rest:produces('application/xml') annotation but the request does not
have a Accept header?

This is what HTTP 1.1 spec[1] says about that:

If no Accept header field is present, then it is assumed that the
client accepts all media types. If an Accept header field is present,
and if the server cannot send a response which is acceptable according
to the combined Accept field value, then the server SHOULD send a 406
(not acceptable) response.

In fact, what does happen is that you get a 404, and this is caused by
the rest:produces annotation. In a REST call you do not always set or
have the option to set an appropriate accept header  (e.g. HTTP client
libraries or when doing doc('http://.') call from XSLT).

I believe that when no Accept header is present the response should
assume that any mediatype is ok. Additionally it would be nice for
REST clients if in case the path matches but the content-negotiation
fails that a 406 would be returned instead of a 404. The latter is
saying the resource does not exist, whereas 406 expresses that the
issue is with the media-type but the resource may exist.

Quite possibly the text in the RESTXQ spec has to be modified as well
in that case because it currentlly reads (consistent with current
behaviour):

If the %rest:produces annotation is specified, a function will
only be invoked if the HTTP Accept header of the request matches one
of the given types.

Would it be possible to get this changed? Or is it maybe better to
take this up in another forum?

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
[2] 
http://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-specification.html#produces-annotation

--Marc


Re: [basex-talk] Bug? Local variable has not been allocated a stack frame slot

2015-04-09 Thread Marc van Grootel
Bummer, it's very tricky to isolate/repro in a minimal case.
At the moment don't have the time to pursue this further.
Maybe later.
--Marc

On Wed, Apr 8, 2015 at 2:27 PM, Marc van Grootel
marc.van.groo...@gmail.com wrote:
 Sure, I'm going to try this evening. If it's indeed Saxon we would
 probably need one anyways.
 --Marc

 On Wed, Apr 8, 2015 at 2:23 PM, Christian Grün
 christian.gr...@gmail.com wrote:
 Hi Marc,

 I would tend to say it's a Saxon issue. We have no Saxon-specific code
 in our XSLT functions, and the complete stack trace seems to indicate
 that something is going wrong in Saxon. – However, I can also have a
 look at this if you send me an SSCCE for that bug.

 Best,
 Christian



 On Wed, Apr 8, 2015 at 2:18 PM, Marc van Grootel
 marc.van.groo...@gmail.com wrote:
 Hi,

 I have hit something which is related to Saxon XSLT. The XSLT in
 question runs fine standalone (via Oxygen). But when hooked up via
 RESTXQ I get the type of tracebacks (i've listed all traceback from
 where it enters Saxon code below).

 Although I don't have a full repro case I did manage to make it run by
 modyfing the expr inside the group-starting-with.

 The code below uses a local variable $i in a predicate. This causes
 the error below.

 xsl:for-each-group select=$v
   group-starting-with=v[xs:integer(@c) eq $i][text()]
 ...
 /xsl:for-each-group

 The code below runs without problems. Here it's not accessing the
 local variable inside the grouping attribute.

 xsl:for-each-group select=$v
   group-starting-with=v[text()]
 ...
 /xsl:for-each-group

 Any idea if this is Saxon or BaseX issue?

 --Marc

 This is the top of the traceback.

 Version: BaseX 8.1
 Java: Oracle Corporation, 1.7.0_25
 OS: Windows 7, amd64
 Stack Trace:
 java.lang.ArrayIndexOutOfBoundsException: Local variable $i
 has not been allocated a stack frame slot
 at 
 net.sf.saxon.expr.LocalVariableReference.evaluateVariable(LocalVariableReference.java:102)
 at 
 net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:453)
 at 
 net.sf.saxon.expr.SingletonAtomizer.evaluateItem(SingletonAtomizer.java:173)
 at 
 net.sf.saxon.expr.SingletonAtomizer.evaluateItem(SingletonAtomizer.java:36)
 at 
 net.sf.saxon.expr.ValueComparison.effectiveBooleanValue(ValueComparison.java:692)
 at 
 net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:139)
 at 
 net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:131)
 at 
 net.sf.saxon.expr.sort.GroupStartingIterator.advance(GroupStartingIterator.java:47)
 at 
 net.sf.saxon.expr.sort.GroupMatchingIterator.next(GroupMatchingIterator.java:75)
 at 
 net.sf.saxon.expr.instruct.ForEachGroup.processLeavingTail(ForEachGroup.java:743)
 at 
 net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:875)
 at 
 net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
 at 
 net.sf.saxon.expr.instruct.UserFunction.process(UserFunction.java:382)
 at 
 net.sf.saxon.expr.UserFunctionCall.process(UserFunctionCall.java:507)
 at 
 net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:662)
 at 
 net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
 at 
 net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:431)
 at 
 net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:373)
 at 
 net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:239)
 at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1057)
 at 
 net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:519)
 at 
 net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:349)
 at 
 net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:323)
 at 
 net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:56)
 at 
 net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:328)
 at net.sf.saxon.expr.LetExpression.eval(LetExpression.java:398)
 at 
 net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:604)
 at 
 net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:875)
 at 
 net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:613)
 at 
 net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:875)
 at 
 net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
 at net.sf.saxon.expr.instruct.Template.expand(Template.java:258)
 at 
 net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:536)
 at net.sf.saxon.Controller.transformDocument(Controller.java:2082

[basex-talk] Bug? Local variable has not been allocated a stack frame slot

2015-04-08 Thread Marc van Grootel
Hi,

I have hit something which is related to Saxon XSLT. The XSLT in
question runs fine standalone (via Oxygen). But when hooked up via
RESTXQ I get the type of tracebacks (i've listed all traceback from
where it enters Saxon code below).

Although I don't have a full repro case I did manage to make it run by
modyfing the expr inside the group-starting-with.

The code below uses a local variable $i in a predicate. This causes
the error below.

xsl:for-each-group select=$v
  group-starting-with=v[xs:integer(@c) eq $i][text()]
...
/xsl:for-each-group

The code below runs without problems. Here it's not accessing the
local variable inside the grouping attribute.

xsl:for-each-group select=$v
  group-starting-with=v[text()]
...
/xsl:for-each-group

Any idea if this is Saxon or BaseX issue?

--Marc

This is the top of the traceback.

Version: BaseX 8.1
Java: Oracle Corporation, 1.7.0_25
OS: Windows 7, amd64
Stack Trace:
java.lang.ArrayIndexOutOfBoundsException: Local variable $i
has not been allocated a stack frame slot
at 
net.sf.saxon.expr.LocalVariableReference.evaluateVariable(LocalVariableReference.java:102)
at 
net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:453)
at 
net.sf.saxon.expr.SingletonAtomizer.evaluateItem(SingletonAtomizer.java:173)
at 
net.sf.saxon.expr.SingletonAtomizer.evaluateItem(SingletonAtomizer.java:36)
at 
net.sf.saxon.expr.ValueComparison.effectiveBooleanValue(ValueComparison.java:692)
at 
net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:139)
at 
net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:131)
at 
net.sf.saxon.expr.sort.GroupStartingIterator.advance(GroupStartingIterator.java:47)
at 
net.sf.saxon.expr.sort.GroupMatchingIterator.next(GroupMatchingIterator.java:75)
at 
net.sf.saxon.expr.instruct.ForEachGroup.processLeavingTail(ForEachGroup.java:743)
at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:875)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
at 
net.sf.saxon.expr.instruct.UserFunction.process(UserFunction.java:382)
at net.sf.saxon.expr.UserFunctionCall.process(UserFunctionCall.java:507)
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:662)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:431)
at 
net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:373)
at 
net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:239)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1057)
at 
net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:519)
at 
net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:349)
at 
net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:323)
at 
net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:56)
at 
net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:328)
at net.sf.saxon.expr.LetExpression.eval(LetExpression.java:398)
at 
net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:604)
at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:875)
at 
net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:613)
at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:875)
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
at net.sf.saxon.expr.instruct.Template.expand(Template.java:258)
at 
net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:536)
at net.sf.saxon.Controller.transformDocument(Controller.java:2082)
at net.sf.saxon.Controller.transform(Controller.java:1903)
at org.basex.query.func.xslt.XsltTransform.transform


Re: [basex-talk] Bug? Local variable has not been allocated a stack frame slot

2015-04-08 Thread Marc van Grootel
Sure, I'm going to try this evening. If it's indeed Saxon we would
probably need one anyways.
--Marc

On Wed, Apr 8, 2015 at 2:23 PM, Christian Grün
christian.gr...@gmail.com wrote:
 Hi Marc,

 I would tend to say it's a Saxon issue. We have no Saxon-specific code
 in our XSLT functions, and the complete stack trace seems to indicate
 that something is going wrong in Saxon. – However, I can also have a
 look at this if you send me an SSCCE for that bug.

 Best,
 Christian



 On Wed, Apr 8, 2015 at 2:18 PM, Marc van Grootel
 marc.van.groo...@gmail.com wrote:
 Hi,

 I have hit something which is related to Saxon XSLT. The XSLT in
 question runs fine standalone (via Oxygen). But when hooked up via
 RESTXQ I get the type of tracebacks (i've listed all traceback from
 where it enters Saxon code below).

 Although I don't have a full repro case I did manage to make it run by
 modyfing the expr inside the group-starting-with.

 The code below uses a local variable $i in a predicate. This causes
 the error below.

 xsl:for-each-group select=$v
   group-starting-with=v[xs:integer(@c) eq $i][text()]
 ...
 /xsl:for-each-group

 The code below runs without problems. Here it's not accessing the
 local variable inside the grouping attribute.

 xsl:for-each-group select=$v
   group-starting-with=v[text()]
 ...
 /xsl:for-each-group

 Any idea if this is Saxon or BaseX issue?

 --Marc

 This is the top of the traceback.

 Version: BaseX 8.1
 Java: Oracle Corporation, 1.7.0_25
 OS: Windows 7, amd64
 Stack Trace:
 java.lang.ArrayIndexOutOfBoundsException: Local variable $i
 has not been allocated a stack frame slot
 at 
 net.sf.saxon.expr.LocalVariableReference.evaluateVariable(LocalVariableReference.java:102)
 at 
 net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:453)
 at 
 net.sf.saxon.expr.SingletonAtomizer.evaluateItem(SingletonAtomizer.java:173)
 at 
 net.sf.saxon.expr.SingletonAtomizer.evaluateItem(SingletonAtomizer.java:36)
 at 
 net.sf.saxon.expr.ValueComparison.effectiveBooleanValue(ValueComparison.java:692)
 at 
 net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:139)
 at 
 net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:131)
 at 
 net.sf.saxon.expr.sort.GroupStartingIterator.advance(GroupStartingIterator.java:47)
 at 
 net.sf.saxon.expr.sort.GroupMatchingIterator.next(GroupMatchingIterator.java:75)
 at 
 net.sf.saxon.expr.instruct.ForEachGroup.processLeavingTail(ForEachGroup.java:743)
 at 
 net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:875)
 at 
 net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
 at 
 net.sf.saxon.expr.instruct.UserFunction.process(UserFunction.java:382)
 at 
 net.sf.saxon.expr.UserFunctionCall.process(UserFunctionCall.java:507)
 at 
 net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:662)
 at 
 net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
 at 
 net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:431)
 at 
 net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:373)
 at 
 net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:239)
 at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1057)
 at 
 net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:519)
 at 
 net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:349)
 at 
 net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:323)
 at 
 net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:56)
 at 
 net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:328)
 at net.sf.saxon.expr.LetExpression.eval(LetExpression.java:398)
 at 
 net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:604)
 at 
 net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:875)
 at 
 net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:613)
 at 
 net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:875)
 at 
 net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
 at net.sf.saxon.expr.instruct.Template.expand(Template.java:258)
 at 
 net.sf.saxon.expr.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:536)
 at net.sf.saxon.Controller.transformDocument(Controller.java:2082)
 at net.sf.saxon.Controller.transform(Controller.java:1903)
 at org.basex.query.func.xslt.XsltTransform.transform



-- 
--Marc


Re: [basex-talk] %unit:ignore broken since 8.0?

2015-03-31 Thread Marc van Grootel
Thanks.
Looking at the code in
basex-core/src/main/java/org/basex/query/ann/Annotation.java

_UNIT_IGNORE(ignore(), arg(), UNIT_URI),

I do indeed see that no arg is allowed. But I wonder what the thinking
behind it is. Being able to put a message there to indicate why the
test was ignored is quite handy to have.

--Marc

On Tue, Mar 31, 2015 at 8:16 AM, Lukas Kircher lukaskirch...@gmail.com wrote:
 Hi Marc,

 sorry for the inconvenience - there have indeed been some changes to the
 unit module in the recent past, that are not yet covered by the
 documentation.
 I assume unit:ignore is one of them (w/o checking the sources). Christian is
 out of town at the moment, so it might take a week before we get back to
 you.

 Cheers,
 Lukas

 On Mon, Mar 30, 2015 at 10:14 PM, Marc van Grootel
 marc.van.groo...@gmail.com wrote:

 Hi,

 Could it be that %unit:ignore(message) is broken since 8.0.

 Whenever I use a message in the annotation my tests fail with this
 error message:

   error line=149 column=21 type=bxerr:BASX0006
   info%unit:ignore: 1 argument supplied./info
   /error

 When (mesage) is removed the test is ok.

 Documentation let's me believe %unit:ignore(message) is still supported.


 --Marc





-- 
--Marc


[basex-talk] %unit:ignore broken since 8.0?

2015-03-30 Thread Marc van Grootel
Hi,

Could it be that %unit:ignore(message) is broken since 8.0.

Whenever I use a message in the annotation my tests fail with this
error message:

  error line=149 column=21 type=bxerr:BASX0006
  info%unit:ignore: 1 argument supplied./info
  /error

When (mesage) is removed the test is ok.

Documentation let's me believe %unit:ignore(message) is still supported.


--Marc


[basex-talk] GUI suggestion: no trace output when running tests

2015-03-21 Thread Marc van Grootel
Hi,

When running tests from the GUI I sometimes insert debugging code to
figure out which tests fails or why. The current behavior of the GUI
makes this impossible though because when tests are run this info is
printed to the Query Info window but immediately after tests are run
it prints the test summary overwriting the debugging info (such as
trace output).

Currently I then go to the command-line but it might be an idea to
somehow keep the output generated during test run visible.

Cheers,
--Marc


[basex-talk] Bug in evaluating conditionals? Not short-circuiting?

2015-03-21 Thread Marc van Grootel
Hi,

I think I found a bug in 8.0.3 (and earlier)

declare function local:shortcircuit($a) {
  if ($a castable as xs:double
  and xs:double($a) gt 0) then
  $a
  else ()
};

local:shortcircuit('foo')

= [FORG0001] Cannot cast to xs:double: foo.

In http://www.w3.org/TR/xpath/#booleans

  An and expression is evaluated by evaluating each operand and
   converting its value to a boolean as if by a call to the boolean function.
  The result is true if both values are true and false otherwise. The right
  operand is not evaluated if the left operand evaluates to false.

Haven't tested it for other conditionals.

--Marc


Re: [basex-talk] get-current-user()

2015-03-21 Thread Marc van Grootel
Hi Christian,

Not sure what else. I'm only starting to delve into this area and I'm
not sure what else would be helpful. In general I'm looking at
creating a small REST atompub service that handles authentication and
this was one of the missing pieces I encountered.

Cheers,


On Sat, Mar 14, 2015 at 4:17 PM, Christian Grün
christian.gr...@gmail.com wrote:
 Maybe I'm missing something but I cannot find the XQuery way to get
 access to the logged in user from a web application using RESTXQ.

 The servlet request object has getRemoteUser and Exist, for example,
 has xmldb:get-current-user and Marklogic has xdmp:get-current-user.

 We could add a function user:current() to the new User Module [1].
 More suggestions on other, possibly missing, functions are welcome.

 Best,
 Christian

 [1] http://docs.basex.org/wiki/User_Module



-- 
--Marc


Re: [basex-talk] Fwd: Re: How to process very long node sequences

2015-03-18 Thread Marc

Hi Hans-Jürgen,
As I understand the first part of answer, you tell that when there is a 
user defined function Basex do cache, but after when you analyze the 
example, you tell that in this cxase there is no cache else there is a 
f:processNode function in the return.


Do I you don't understand?

Marc

Le 18/03/2015 19:38, Leonard Wörteler a écrit :

Wrong mail account...

 Weitergeleitete Nachricht 
Betreff: Re: [basex-talk] How to process very long node sequences
Datum: Wed, 18 Mar 2015 19:26:00 +0100
Von: Leo Wörteler l...@basex.org
An: Hans-Juergen Rennau hren...@yahoo.de
Kopie (CC): basex-talk@mailman.uni-konstanz.de
basex-talk@mailman.uni-konstanz.de

Dear Hans-Jürgen,

Am 18.03.2015 um 15:23 schrieb Hans-Juergen Rennau:

I want to persuade the processor to visit, process and forget the nodes
one after the other, rather than to attempt loading all nodes into
memory before proceeding to process them.


BaseX already uses iterative processing as default mode. It only falls
back to caching if it has to, e.g. for sorting, reversing or duplicate
elimination. Calls to user-defined functions are currently also
blocking, but we are currently investigating if that can be changed.


Schematically:

declare function f:processNode($node as node())  as empty-sequence()
{...};

for $node in doc('huge-doc')/a/b/c
return f:processNode($node)


The example you gave will always be evaluated without caching the node
sequence. The `for` clause requests the result of its argument
iteratively, and the XPath expression you used only contains child
steps, which can be evaluated in document order without duplicates.


Well, in some cases it works, in others in doesn't. Is there any safe
way how to enforce sequential visit-process-forget processing?


When the XPath expression becomes more complex, it is not as easy to
predict if it uses caching internally. BaseX tries quite hard to detect
paths that do not need it, the algorithm can be seen in [1]. If you see
a `CachedPath` in the Info View of the GUI, you can try to reformulate
the query.


I call this problem general because it is a critical aspect of dealing
with huge documents.


XQuery does not have a dedicated *streaming mode* like
that of XSLT 3.0 [2] (yet), but it would definitely be possible to check
if some part of a query (e.g. marked by a pragma) is evaluated without
caching. It would however be quite some work.

Hope that helps,
   Leo

[1]
https://github.com/BaseXdb/basex/blob/0b828a8/basex-core/src/main/java/org/basex/query/expr/path/Path.java#L297-359

[2] http://www.w3.org/TR/xslt-30/#dt-guaranteed-streamable


[basex-talk] get-current-user()

2015-03-14 Thread Marc van Grootel
Hi,

Maybe I'm missing something but I cannot find the XQuery way to get
access to the logged in user from a web application using RESTXQ.

The servlet request object has getRemoteUser and Exist, for example,
has xmldb:get-current-user and Marklogic has xdmp:get-current-user.

I don't need to know intricate user details just need the handle on
the logged in / authenticated user (possibly from the servlet request
object?)

--Marc


Re: [basex-talk] DITA project

2015-03-13 Thread Marc van Grootel
Hi France,

If you really need multi-branching if then else the language doesnt require 
increasing indentation.

  if (cond1)
  then expr1
  else if (cond2)
  then expr2
  else expr3

In my opinion this is just as good as using switch, i've seen examples like 
this even in the spec. Of course readability suffers if there's a lot going on 
in the expressions such as complete flwor expressions but that's just a matter 
of breaking up the code in smaller (re-usable) pieces/functions.

Breaking up / refactoring your logic to avoid massive if then else or switch 
constructs is advisable anyway. But I don't know how your code looks so I 
cannot say.

hth
--Marc

Re: [basex-talk] DITA project

2015-03-12 Thread Marc van Grootel
Hi France,

Typeswitch is not the right tool for this.

From the spec:

[74]TypeswitchExpr ::=  typeswitch ( Expr ) CaseClause+ 
default ($ VarName)? return ExprSingle
[75]CaseClause ::=  case ($ VarName as)? 
SequenceTypeUnion return ExprSingle
[76]SequenceTypeUnion  ::=  SequenceType (| SequenceType)*


As the name implies it is meant for checking (sequence) types and not for 
arbitrary XPath expressions.

Also, using contains isn't watertight as contains('foobar','foo') would match 
as well. I would probably use a function like this

declare function in-class($node as element(), $class as xs:string) as 
xs:boolean {
  $class = tokenize($node/@class,'\s+')
}

Do check performance in your situation. In case you need to do many checks on 
the same class attribute you may want to bind the tokenized value list with a 
let instead of using this function.

I also remember that Michael Kay is looking into improving on exactly this use 
case. But that doesn't help you now.

Cheers,
--Marc

 On 12 mrt. 2015, at 20:33, France Baril france.ba...@architextus.com wrote:
 
 Hi, 
 
 I'm working on a new DITA project. The DITA standard is used for technical 
 documentation. It creates XML models with inheritance by using 
 @class=ancestor parent child. If the child should behave like it's ancestor 
 the XSL would say: 
template match=contains(@class, 'ancestor') ... /template 
 
 The advantage is that the model can evolve and when new elements are added, 
 you only need to code transformations for the differences.
 
 I am trying to figure out if I can use type switching with contains in 
 attribute. Search gets me no syntax for something like this:
 
  typeswitch ($node)
 case attribute(contains(class, 'ancestor'))
 
 Maybe I should register to the xquery group to get an answer, but since I'm 
 already here, I though I should ask, and maybe there is a BaseX specific 
 option. I mean other that an unmanageable number of 'if then else' statements.
 
 Thanks!
 
 
 
 -- 
 France Baril
 Architecte documentaire / Documentation architect
 france.ba...@architextus.com


  1   2   3   >