[basex-talk] Repeating "bin/basexhttp -S" and "bin/basexhttpstop"

2020-09-13 Thread AirQuick
Repeating "bin/basexhttp -S" and "bin/basexhttpstop" is no longer supported?

On BaseX 9.4.1 and 9.4.2, you can repeat:

$ java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)
$ BaseX941/basex/bin/basexhttp -S
/tmp/BaseX941/basex/.basex: writing new configuration file.
BaseX 9.4.1 [HTTP Server]
[main] INFO org.eclipse.jetty.util.log - Logging initialized @676ms to 
org.eclipse.jetty.util.log.Slf4jLog
HTTP Server was started (port: 8984).
Server was started (port: 1984).
$ BaseX941/basex/bin/basexhttpstop
BaseX 9.4.1 [HTTP Server]
[main] INFO org.eclipse.jetty.util.log - Logging initialized @227ms to 
org.eclipse.jetty.util.log.Slf4jLog
HTTP Server was stopped (port: 8984).
Server was stopped (port: 1984).
$ BaseX941/basex/bin/basexhttp -S
BaseX 9.4.1 [HTTP Server]
[main] INFO org.eclipse.jetty.util.log - Logging initialized @231ms to 
org.eclipse.jetty.util.log.Slf4jLog
HTTP Server was started (port: 8984).
Server was started (port: 1984).
$ BaseX941/basex/bin/basexhttpstop
BaseX 9.4.1 [HTTP Server]
[main] INFO org.eclipse.jetty.util.log - Logging initialized @237ms to 
org.eclipse.jetty.util.log.Slf4jLog
HTTP Server was stopped (port: 8984).
Server was stopped (port: 1984).

On 9.4.3, you can't:

$ BaseX943/basex/bin/basexhttp -S
/tmp/BaseX943/basex/.basex: writing new configuration file.
BaseX 9.4.3 [HTTP Server]
[main] INFO org.eclipse.jetty.util.log - Logging initialized @309ms to 
org.eclipse.jetty.util.log.Slf4jLog
HTTP Server was started (port: 8984).
Server was started (port: 1984).
$ BaseX943/basex/bin/basexhttpstop 
BaseX 9.4.3 [HTTP Server]
[main] INFO org.eclipse.jetty.util.log - Logging initialized @250ms to 
org.eclipse.jetty.util.log.Slf4jLog
HTTP Server was stopped (port: 8984).
Server was stopped (port: 1984).
$ BaseX943/basex/bin/basexhttp -S
BaseX 9.4.3 [HTTP Server]
[main] INFO org.eclipse.jetty.util.log - Logging initialized @254ms to 
org.eclipse.jetty.util.log.Slf4jLog
[main] INFO org.eclipse.jetty.util.log - Logging initialized @225ms to 
org.eclipse.jetty.util.log.Slf4jLog
[main] INFO org.eclipse.jetty.server.Server - jetty-9.4.31.v20200723; built: 
2020-07-23T17:57:36.812Z; git: 450ba27947e13e66baa8cd1ce7e85a4461cacc1d; jvm 
1.8.0_261-b12
[main] INFO org.eclipse.jetty.webapp.StandardDescriptorProcessor - NO JSP 
Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
[main] INFO org.eclipse.jetty.server.session - DefaultSessionIdManager 
workerName=node0
[main] INFO org.eclipse.jetty.server.session - No SessionScavenger set, using 
defaults
[main] INFO org.eclipse.jetty.server.session - node0 Scavenging every 60ms
[main] WARN org.eclipse.jetty.server.handler.ContextHandler.ROOT - unavailable
org.basex.core.BaseXException: Server is running or permission was denied 
(port: 1984).
at org.basex.BaseXServer.(BaseXServer.java:108)
at org.basex.http.HTTPContext.init(HTTPContext.java:102)
at org.basex.http.BaseXServlet.init(BaseXServlet.java:37)
at 
org.eclipse.jetty.servlet.ServletHolder$WrapperServlet.init(ServletHolder.java:1289)
at 
org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:602)
at 
org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:413)
at 
org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:767)
at 
java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:352)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:483)
at 
java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at 
java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
at 
java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)
at 
java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at 
org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)
at 
org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:360)
at 
org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1445)
at 
org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1409)
at 
org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:855)
at 
org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:275)
at 
org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
at 
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
at 
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
at org.eclipse.jetty.server.Server.start(Server.java:408)
at 
org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
at 
org

[basex-talk] Package for system integration

2020-09-13 Thread karlo
I have packaged basex in a way that I believe will be easier
for integration with package managers.
https://klarinet.kos.ovh/fossil/basex-root-install/uv/basex-9.4.3.tar.gz

>From the root of that archive, you can build and install like this.

  make
  make install # as root

The above will install to the prefix /usr/local. You can set
a different prefix. Here is an example.

  make clean
  make PREFIX=/usr
  make PREFIX=/usr install # as root

A secondary benefit of this package is the removal of the bash
dependency.

Could a package like this be distributed officially? If that is
agreeable, I am happy to try incorporating this into the present
build system.

Here is a utility for preparing the package. It depends on sh and other
Unix-like utilities.
https://klarinet.kos.ovh/fossil/basex-root-install/dir?ci=tip

With distinguished salutations,
Kralj Karlo


Re: [basex-talk] Best way to re-create existing root element with all attributes

2020-09-13 Thread Martin Honnen

On 13.09.2020 21:46, Yitzhak Khabinsky wrote:

Hello,

This is input XML:


Peter
Director

John
Animator

James
Assistant




Desired output XML:


Peter
Director


Overall, it is a so called ‘modified identity transformation’ in XSLT
parlance.

Output XML shall be the same, except the child  element and
its children.

**

Question:

*What is the best way to re-create existing root element with all its
attributes?*

My implementation:

xquery version "3.1";

declare context item := document {



     Peter

     Director

     

     John

     Animator

     

     James

     Assistant

     

     



};

(: working version :)

element {fn:node-name(/*)}

{

let $y :=  ./*/@*

return $y,    (: copy all attributes :)

for $x in ./*/(* except employee)

return $x

}

(: NOT working version, trying to make it more concise :)



I would write

  /*/element { node-name() } { @*, * except employee }





Re: [basex-talk] Best way to re-create existing root element with all attributes

2020-09-13 Thread Christian Grün
Hi Yitzhak,

Try this:

  declare context item := document { ... };
  * update {
delete node employee
  }

See [1] for more information on updating expressions.

Best,
Christian

[1] https://docs.basex.org/wiki/XQuery_Update


On 9/13/20, Yitzhak Khabinsky  wrote:
> Hello,
>
>
>
> This is input XML:
>
> 
> Peter
> Director
> 
> John
> Animator
> 
> James
> Assistant
> 
> 
> 
>
>
>
> Desired output XML:
>
> 
> Peter
> Director
> 
>
>
>
> Overall, it is a so called 'modified identity transformation' in XSLT
> parlance.
>
> Output XML shall be the same, except the child  element and its
> children.
>
>
>
> Question:
>
> What is the best way to re-create existing root element with all its
> attributes?
>
>
>
> My implementation:
>
> xquery version "3.1";
>
>
>
> declare context item := document {
>
> 
>
> Peter
>
> Director
>
> 
>
> John
>
> Animator
>
> 
>
> James
>
> Assistant
>
> 
>
> 
>
> 
>
> };
>
>
>
> (: working version :)
>
> element {fn:node-name(/*)}
>
> {
>
> let $y :=  ./*/@*
>
> return $y,(: copy all attributes :)
>
> for $x in ./*/(* except employee)
>
> return $x
>
> }
>
>
>
> (: NOT working version, trying to make it more concise :)
>
> element {fn:node-name(/*)} {/*/@*}
>
> {
>
> return for $x in ./*/(* except employee)
>
> return $x
>
> }
>
>
>
>
>
> Regards,
> Yitzhak Khabinsky
>
>
>
>
>
>


[basex-talk] Best way to re-create existing root element with all attributes

2020-09-13 Thread Yitzhak Khabinsky
Hello,

 

This is input XML:


Peter
Director

John
Animator

James
Assistant


 

 

Desired output XML:


Peter
Director
 

 

Overall, it is a so called 'modified identity transformation' in XSLT
parlance.

Output XML shall be the same, except the child  element and its
children.

 

Question:

What is the best way to re-create existing root element with all its
attributes?

 

My implementation:

xquery version "3.1";

 

declare context item := document {



Peter

Director



John

Animator



James

Assistant







};

 

(: working version :)

element {fn:node-name(/*)}

{

let $y :=  ./*/@*

return $y,(: copy all attributes :)

for $x in ./*/(* except employee)

return $x

}

 

(: NOT working version, trying to make it more concise :)

element {fn:node-name(/*)} {/*/@*}

{

return for $x in ./*/(* except employee)

return $x

}

 

 

Regards,
Yitzhak Khabinsky



 



Re: [basex-talk] tail recursion issue in 9.4.3

2020-09-13 Thread Mark McSweeny

Hi, Christian:

I can confirm that the BaseX944-20200913.183608 snapshot corrects the 
issue, for both my toy example and the original full query.


Thanks for your quick response.

Take care,

Mark


On 2020-09-13 10:42, Christian Grün wrote:

Hi Mark,

With BaseX 9.4.3, your FLWOR expression will be rewritten to a simple
map expression – for which no TCOs detection was implemented so far.
It works with the latest snapshot [1].

If you want to stick with 9.4.3, you can manually inline $x:

declare function local:f($n, $xs) {
   if ($n = 0) then $xs else local:f($n - 1, ($xs,
 copy $node := 
 modify rename node $node as 'x'
 return $node
   ))
};
local:f(2000, ())

Hope this helps
Christian

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


On 9/13/20, Mark McSweeny  wrote:

Hello,

I have encountered a difference in behaviour between versions 9.3.3 and
9.4.3 for a certain query involving tail recursion.  In 9.3.3 the
compiled query plan correctly applied tail call optimization.  But in
9.4.3 tail call optimization is not applied, resulting in a stack
overflow during execution.

Here is a minimal query that demonstrates the issue:


declare function local:f($n, $xs)
{
if ($n = 0) then $xs
else
  let $x :=
copy $node :=  modify ( rename node $node as 'x') return $node
  return local:f($n - 1, ($xs, $x))
};
local:f(2000, ())



Mark




Re: [basex-talk] tail recursion issue in 9.4.3

2020-09-13 Thread Christian Grün
Hi Mark,

With BaseX 9.4.3, your FLWOR expression will be rewritten to a simple
map expression – for which no TCOs detection was implemented so far.
It works with the latest snapshot [1].

If you want to stick with 9.4.3, you can manually inline $x:

declare function local:f($n, $xs) {
  if ($n = 0) then $xs else local:f($n - 1, ($xs,
copy $node := 
modify rename node $node as 'x'
return $node
  ))
};
local:f(2000, ())

Hope this helps
Christian

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


On 9/13/20, Mark McSweeny  wrote:
> Hello,
>
> I have encountered a difference in behaviour between versions 9.3.3 and
> 9.4.3 for a certain query involving tail recursion.  In 9.3.3 the
> compiled query plan correctly applied tail call optimization.  But in
> 9.4.3 tail call optimization is not applied, resulting in a stack
> overflow during execution.
>
> Here is a minimal query that demonstrates the issue:
>
>
> declare function local:f($n, $xs)
> {
>if ($n = 0) then $xs
>else
>  let $x :=
>copy $node :=  modify ( rename node $node as 'x') return $node
>  return local:f($n - 1, ($xs, $x))
> };
> local:f(2000, ())
>
>
>
> Mark
>
>


[basex-talk] tail recursion issue in 9.4.3

2020-09-13 Thread Mark McSweeny

Hello,

I have encountered a difference in behaviour between versions 9.3.3 and 
9.4.3 for a certain query involving tail recursion.  In 9.3.3 the 
compiled query plan correctly applied tail call optimization.  But in 
9.4.3 tail call optimization is not applied, resulting in a stack 
overflow during execution.


Here is a minimal query that demonstrates the issue:


declare function local:f($n, $xs)
{
  if ($n = 0) then $xs
  else
let $x :=
  copy $node :=  modify ( rename node $node as 'x') return $node
return local:f($n - 1, ($xs, $x))
};
local:f(2000, ())



Mark