Db creation

Sunday, 30 August 2015 · 7 messages · last reply 17 Sep 2015
M
meumapple30 Aug 2015 17:02 #
Hi, I am trying to open a collection of files where some of them contain character entity references like &ndash; which are not declared in the document and so make basex crash if I use collection() If I use file:read-text for each file and then put this functioni in file:write, the saved text will show &lt; &gt; instead of < and >: why? Moreover, if I create a database from the GUI and select the option "skip corrupt", the database is created. However if I follow instruction here http://docs.basex.org/wiki/Parsers In order to add single files to a db usind db:add and precede the query with declare option db:skipcorrupt 'true', the files are not added because I get an error message due to the not well-formed xml. I have tried to declare other db options in the same way but they seem not be read. Giuseppe
M
meumapple3 Sep 2015 13:05 #
Hi, I forward a message I sent a few days ago which apparently did not receive any answer. I am trying to open a collection of files where some of them contain character entity references like &ndash; which are not declared in the document and so make basex crash if I use collection() If I use file:read-text for each file I can open them, but if I then put this functioni in file:write, the saved text will show &lt; &gt; instead of < and >: why? Moreover, if I create a database from the GUI and select the option "skip corrupt", the database is created. However if I follow instruction here http://docs.basex.org/wiki/Parsers In order to add single files to a db using db:add and precede the query with declare option db:skipcorrupt 'true', the files are not added because I get an error message due to the not well-formed xml (which means that the declaration at the beginning of the query is not read). I have tried to declare other db options in the same way (ie in the prolog of a script) but they seem not be read. Giuseppe
DK
Dirk Kirsten3 Sep 2015 14:37 #
Hello Joseph, sorry, I didn't have much time to reply to your mail before. So, using file:write without any optimization parameters it will most likely try to serialize as XML and then it should replace e.g. < by &lt;. Instead, you could use file:write-text() or set the seriaziation method explicitely, i.e. using file:write(<path>, <data>, map { "method": "text" }) Using skipcorrupt should indeed work. Could you please send us the concrete snippet you are trying to execute? And also, which BaseX version are you using? Cheers Dirk
Quoted text · meumapple · 13 lines
On 09/03/2015 01:05 PM, meumapple wrote: > Hi, > > I forward a message I sent a few days ago which apparently did not receive any answer. I am trying to open a collection of files where some of them contain character entity references like &ndash; which are not declared in the document and so make basex crash if I use collection() > > If I use file:read-text for each file I can open them, but if I then put this functioni in file:write, the saved text will show &lt; &gt; instead of < and >: why? > > Moreover, if I create a database from the GUI and select the option "skip corrupt", the database is created. However if I follow instruction here http://docs.basex.org/wiki/Parsers > In order to add single files to a db using db:add and precede the query with declare option db:skipcorrupt 'true', the files are not added because I get an error message due to the not well-formed xml (which means that the declaration at the beginning of the query is not read). I have tried to declare other db options in the same way (ie in the prolog of a script) but they seem not be read. > > Giuseppe > >
-- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
CG
Christian Grünin reply to meumapple, 30 Aug 2015, 17:0214 Sep 2015 12:45 #
Hi Giuseppe,
Quoted text · meumapple · 1 line
> I am trying to open a collection of files where some of them contain character entity references like &ndash; which are not declared in the document and so make basex crash if I use collection()
Could you please give us more information what "basex crash" means in this context?
Quoted text · meumapple · 1 line
> If I use file:read-text for each file and then put this functioni in file:write, the saved text will show &lt; &gt; instead of < and >: why?
Dirk already gave you the answer I think. Here are two possible alternatives:
  try {
    doc(...)
  } catch * {
    () (: file is corrupt :)
  }

 try {
    parse-xml(file:read-text(...))
  } catch * {
    () (: file is corrupt :)
  }
Best, Christian
Quoted text · meumapple · 8 lines
> > > Moreover, if I create a database from the GUI and select the option "skip corrupt", the database is created. However if I follow instruction here http://docs.basex.org/wiki/Parsers > In order to add single files to a db usind db:add and precede the query with declare option db:skipcorrupt 'true', the files are not added because I get an error message due to the not well-formed xml. I have tried to declare other db options in the same way but they seem not be read. > > Giuseppe > >
CG
Christian Grünin reply to meumapple, 30 Aug 2015, 17:0214 Sep 2015 15:44 #
I forgot to give feedback to your last comment:
Quoted text · meumapple · 2 lines
> Moreover, if I create a database from the GUI and select the option "skip corrupt", the database is created. However if I follow instruction here http://docs.basex.org/wiki/Parsers > In order to add single files to a db usind db:add and precede the query with declare option db:skipcorrupt 'true', the files are not added because I get an error message due to the not well-formed xml. I have tried to declare other db options in the same way but they seem not be read.
Thanks for pointing this out. The examples in the Wiki were outdated; I have just updated them. The way to do it now is to specify the options as function arguments. Christian
M
meumapple16 Sep 2015 23:56 #
So...you mean that "declare db:skipcorrupt ... " is not a valid syntax anymore?
Quoted text · Christian Grün · 1 line
Il giorno 14/set/2015, alle ore 15:44, Christian Grün <christian.gruen at gmail.com> ha scritto:
I forgot to give feedback to your last comment:
Quoted text · Christian Grün · 2 lines
> Moreover, if I create a database from the GUI and select the option "skip corrupt", the database is created. However if I follow instruction here http://docs.basex.org/wiki/Parsers > In order to add single files to a db usind db:add and precede the query with declare option db:skipcorrupt 'true', the files are not added because I get an error message due to the not well-formed xml. I have tried to declare other db options in the same way but they seem not be read.
Thanks for pointing this out. The examples in the Wiki were outdated; I have just updated them. The way to do it now is to specify the options as function arguments. Christian
CG
Christian Grün17 Sep 2015 09:27 #
Quoted text · meumapple · 1 line
> So...you mean that "declare db:skipcorrupt ... " is not a valid syntax anymore?
The syntax "declare option ..." is still valid, but many options don't apply to functions anymore. As it's not clearly documented what options are interpreted by XQuery functions, it may be that we will completely remove global BaseX options in future, or at least restrict them to a well-defined subset.
Quoted text · Christian Grün · 13 lines
> > Il giorno 14/set/2015, alle ore 15:44, Christian Grün <christian.gruen at gmail.com> ha scritto: > > I forgot to give feedback to your last comment: > >> Moreover, if I create a database from the GUI and select the option "skip corrupt", the database is created. However if I follow instruction here http://docs.basex.org/wiki/Parsers >> In order to add single files to a db usind db:add and precede the query with declare option db:skipcorrupt 'true', the files are not added because I get an error message due to the not well-formed xml. I have tried to declare other db options in the same way but they seem not be read. > > Thanks for pointing this out. The examples in the Wiki were outdated; > I have just updated them. The way to do it now is to specify the > options as function arguments. > > Christian

⚡Generated with XQuery