Re: [basex-talk] BaseX subcollections

2015-08-13 Thread Dirk Kirsten
Hello Tim,

I am not sure I understand your question completely. Basically every way
how you can add a document to a database you can specify a path, e.g.
using the XQuery database module or by using the CREATE document to
create a new database and initialize it. Is there anything specific you
are looking for?

Also, please not that BaseX 6.3.1 is _very_ outdated... I don't think
you can find much valuable information there except looking for the
history of BaseX.

Cheers
Dirk

On 08/12/2015 07:15 PM, Tim Thompson wrote:
 Hello,

 I see that I can create subcollections or paths within a database if I
 create the database then use the ADD TO command to add a resource at
 a specified path. Is this the only way to create hiearchical structure
 within a database? I couldn't find many details about this in the
 documentation.

 I see that the changelog for BaseX 6.3.1 includes,[ADD] REST: support
 for hierarchical collections added; details will follow, but I don't
 see anything about this in the wiki page for the REST module.

 Thanks in advance,
 Tim

 --
 Tim A. Thompson
 Metadata Librarian (Spanish/Portuguese Specialty)
 Princeton University Library


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



[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] HTTP response and raising error()

2015-08-13 Thread Dirk Kirsten
Hello Marc,

you are correct. This is the advantage if you see the XQuery code
Christian writes, you will discover all the undocumented magic things.

But I added a little documentation at
http://docs.basex.org/wiki/RESTXQ#XQuery_Errors, so you all know how you
can return the mighty 418 status code :)

Cheers
Dirk

On 08/13/2015 04:33 PM, Marc van Grootel wrote:
 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



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



Re: [basex-talk] BaseX subcollections

2015-08-13 Thread Tim Thompson
Thanks, Dirk. Basically, I just want to create hierarchical collections
within a database, with some subcollections being possible empty. But if I
do CREATE DB parent, I'm not able to follow that with something like, CREATE
DB parent/child. Is this possible by other means? (Sorry for the newbie
question; I'm still getting familiarized with how things work in BaseX.)

Tim

--
Tim A. Thompson
Metadata Librarian (Spanish/Portuguese Specialty)
Princeton University Library


On Thu, Aug 13, 2015 at 6:07 AM, Dirk Kirsten d...@basex.org wrote:

 Hello Tim,

 I am not sure I understand your question completely. Basically every way
 how you can add a document to a database you can specify a path, e.g. using
 the XQuery database module or by using the CREATE document to create a new
 database and initialize it. Is there anything specific you are looking for?

 Also, please not that BaseX 6.3.1 is _very_ outdated... I don't think you
 can find much valuable information there except looking for the history of
 BaseX.

 Cheers
 Dirk


 On 08/12/2015 07:15 PM, Tim Thompson wrote:

 Hello,

 I see that I can create subcollections or paths within a database if I
 create the database then use the ADD TO command to add a resource at a
 specified path. Is this the only way to create hiearchical structure within
 a database? I couldn't find many details about this in the documentation.

 I see that the changelog for BaseX 6.3.1 includes, [ADD] REST: support
 for hierarchical collections added; details will follow, but I don't see
 anything about this in the wiki page for the REST module.

 Thanks in advance,
 Tim

 --
 Tim A. Thompson
 Metadata Librarian (Spanish/Portuguese Specialty)
 Princeton University Library


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




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

2015-08-13 Thread Christian Grün
Hi Marc,

 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.

The rationale behind this was that a RESTXQ developer can use fn:error
functions, which are triggered when the client sends invalid input.
But it's true that 500 codes may be more appropriate if the server
code is buggy indeed.

Unfortunately, it's not really possible to detect if an error was
explicitly raised in the XQuery code, or if it was unexpected. Errors
starting with XPST usually indicate parsing errors, but even those
codes can be manually generated:

  fn:error(xs:QName('err:XPST0003'), 'Hehe')

 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.

Could you write more about your use case? Do you expect your code to
be buggy, or when do errors occur?

Christian

PS: Dirk may give you another reply on the third argument of fn:error.
I'm not sure if it really works (but never forget I'm getting older
every day ;)


Re: [basex-talk] BaseX subcollections

2015-08-13 Thread Christian Grün
Hi Tim,

There is no fixed collection layer in BaseX. However, a single
database can contain millions of documents with arbitrary paths, and
you can always specify target paths when adding or replacing
documents. This also applies if you add more than one file at a time:

  OPEN db1
  ADD TO /colls/coll1 c:/xml/files/on/my/disk

…or via XQuery (and binary resources):

  for $f in file:children('c:/users/user/desktop')
  return db:store('db1', 'coll/' || file:name($f), file:read-binary($f))

Our documentation on databases may shed some more light on this [1].

Best,
Christian

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



On Thu, Aug 13, 2015 at 7:13 PM, Tim Thompson timat...@gmail.com wrote:
 Thanks, Dirk. Basically, I just want to create hierarchical collections
 within a database, with some subcollections being possible empty. But if I
 do CREATE DB parent, I'm not able to follow that with something like, CREATE
 DB parent/child. Is this possible by other means? (Sorry for the newbie
 question; I'm still getting familiarized with how things work in BaseX.)

 Tim

 --
 Tim A. Thompson
 Metadata Librarian (Spanish/Portuguese Specialty)
 Princeton University Library


 On Thu, Aug 13, 2015 at 6:07 AM, Dirk Kirsten d...@basex.org wrote:

 Hello Tim,

 I am not sure I understand your question completely. Basically every way
 how you can add a document to a database you can specify a path, e.g. using
 the XQuery database module or by using the CREATE document to create a new
 database and initialize it. Is there anything specific you are looking for?

 Also, please not that BaseX 6.3.1 is _very_ outdated... I don't think you
 can find much valuable information there except looking for the history of
 BaseX.

 Cheers
 Dirk


 On 08/12/2015 07:15 PM, Tim Thompson wrote:

 Hello,

 I see that I can create subcollections or paths within a database if I
 create the database then use the ADD TO command to add a resource at a
 specified path. Is this the only way to create hiearchical structure within
 a database? I couldn't find many details about this in the documentation.

 I see that the changelog for BaseX 6.3.1 includes, [ADD] REST: support for
 hierarchical collections added; details will follow, but I don't see
 anything about this in the wiki page for the REST module.

 Thanks in advance,
 Tim

 --
 Tim A. Thompson
 Metadata Librarian (Spanish/Portuguese Specialty)
 Princeton University Library


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