Hi,
Probably my previous mail got lost somewhere, so here it is again.
Regards,
Rob Stapper
Van: Rob Stapper [mailto:r.stapper@lijbrandt.nl]
Verzonden: dinsdag 8 september 2015 16:16
Aan: BaseX
Onderwerp: duplicate declaration error-message when using dynamic
module-imports ( inspect:functions)
Hi,
I get a "duplicate declaration" error-message when I using the
inspect:functions-function.
Consider program: testRun1-2a.xq. The program imports module: module1.xqm
and module2a.xqm.
Module: module1.xqm, declares a variable: $mod1:x, and a function:
mod1:show( $x).
Module: module2a.xqm, declare a function: mod2a:run, which calls a function
by a given function-name: $name in a dynamically imported module by a given
module-uri: $uri.
Program: testRun1-2a.xq, calls the run-function in module2a and tells it to
use variable: $mod1:x, on function: mod1:show in module: module1.xqm.
This triggers an error: Duplicate declaration on static variable $mod1:x.
On the other hand, program: testRun1-2b.xq, does exactly the same except
that module:module2b.xqm, is statically linked to module: module1.xqm,
instead of dynamically as happens in module:module2a.xqm.
Shouldn't the dynamically import of modules behave in the same manner as its
static counterpart?
Is it possible to achieve this?
Cheers,
Rob
PS the examples are a bit awkward but in my real-life program this
construction makes sense (to my anyway).
---
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
https://www.avast.com/antivirus
Sorry and thanks for the answer.
Michele
--------- Original Message --------
Da: "Dirk Kirsten" <dk(a)basex.org>
To:
Cc: "Maximilian Gärber"
<mgaerber(a)arcor.de>de>, basex-talk(a)mailman.uni-konstanz.de
Oggetto: Re: [basex-talk] problem with prepared
Data: 10/09/15 10:28
Hello Michele,
please always make sure to send us a SSCCEE (see http://sscce.org/). It is
very time-consuming to read such a large XQuery and I highly doubt all this
is relevant for your actual problem.
Also, I highly doubt that you need 8 (!) for-loops, which are all nested.
This takes an execution time of n^8, which is **a lot**, even for small
values of n.
Also, all your for loops seem to do basically the same and work on the same
data, so I doubt that it is really neccessary.
Based on this and your previous questions I would recommend you to get a
better understanding of XQuery before tackling your actual problem.
Otherwise, you will always stumble across new problems, which you could self
yourself better and faster if you know the core conecpts. I can recommend
the XQuery book by Priscilla Walmsley, I also find the wikibook about XQuery
(https://en.wikibooks.org/wiki/XQuery) quite useful.
As part of our commercial offering we also offer seminars or on-site
training (see http://basexgmbh.de/en/). If you are interested, please
contact us in private.
Regards,
Dirk
On 09/10/2015 10:10 AM, michele.greco2(a)email.it wrote:
Thanks for the help ,Max. I modified my xquery this way:
declare namespace pkg="http://schemas.microsoft.com/office/2006/xmlPackage";
declare namespace
w="http://schemas.openxmlformats.org/wordprocessingml/2006/main";
declare function local:indice() as xs:integer* {
for $i in(1 to count(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nome"]
return $e/./following::text()except
(for $x in doc($c)//w:tc[.//text()="Indirizzo"]
return $x//following::text())))
return $i
};
declare function local:nome() as xs:string* {
for $n in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nome"]
return $e/./following::text()except
(for $x in doc($c)//w:tc[.//text()="Indirizzo"]
return $x//following::text()))
return $n
};
declare function local:indirizzo() as xs:string* {
for $in in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Indirizzo"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="Telefono"]
return $x//following::text()))
return $in
};
declare function local:telefono() as xs:string* {
for $t in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Telefono"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="Fax"]
return $x//following::text()))
return $t
};
declare function local:fax() as xs:string* {
for $f in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Fax"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="E-mail"]
return $x//following::text()))
return $f
};
declare function local:email() as xs:string* {
for $em in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="E-mail"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="Nazionalità"]
return $x//following::text()))
return $em
};
declare function local:nazionalita() as xs:string* {
for $na in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nazionalità"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text() ="D" ]
return $x//following::text()))
return $na
};
declare function local:dataNascita() as xs:string* {
for $d in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Data di nascita"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="Esperienza lavorativa"]
return $x//following::text()))
return $d
};
for $indice at $pos in local:indice()
for $nome in local:nome() [$pos]
for $indirizzo in local:indirizzo()[$pos]
for $telefono in local:telefono()[$pos]
for $fax in local:fax()[$pos]
for $email in local:email()[$pos]
for $nazionalita in local:nazionalita()[$pos]
for $datanascita in local:dataNascita()[$pos]
let $init := sql:init("com.mysql.jdbc.Driver"),
$conn :=
sql:connect("jdbc:mysql://localhost:3306/DbName","user","password''),
$stmt := sql:prepare($conn, "INSERT INTO
informazionipersonali(idInformazioniPersonali,nome,indirizzo,telefono,fax,email,nazionalità,dataNascita)
VALUES(?,?,?,?,?,?,?,?) ")
let $params:= <sql:parameters>
<sql:parameter
type="int">{$indice}</sql:parameter>
<sql:parameter
type="string">{$nome}</sql:parameter>
<sql:parameter
type="string">{$indirizzo}</sql:parameter>
<sql:parameter
type="string">{$telefono}</sql:parameter>
<sql:parameter
type="string">{$fax}</sql:parameter>
<sql:parameter
type="string">{$email}</sql:parameter>
<sql:parameter
type="string">{$nazionalita}</sql:parameter>
<sql:parameter
type="string">{$datanascita}</sql:parameter>
</sql:parameters>
return sql:execute-prepared($stmt,$params)
It works,but it returns only the first row in my database, and i want a row
for each value (indice,nome,indirizzo,........)
How can i do?
--------- Original Message --------
Da: "Maximilian Gärber" <mgaerber(a)arcor.de>
To: "basex-talk(a)mailman.uni-konstanz.de"
<basex-talk(a)mailman.uni-konstanz.de>
Oggetto: Re: [basex-talk] problem with prepared
Data: 09/09/15 09:12
or using a where statement
for $indice at $pos in local:indice()
for $nome at $pos2 in local:nome()
let $params:= <sql:parameters>
<sql:parameter type="int">{$indice}</sql:parameter>
<sql:parameter type="string">{$nome}</sql:parameter>
</sql:parameters>
where $pos2 = $pos
return $params
2015-09-09 9:05 GMT+02:00 Maximilian Gärber <mgaerber(a)arcor.de>de>:
> Hi,
>
> when you join (by nesting for statements) you will always get the
> combinations unless you provide more constraints.
>
> You might try something like:
>
> declare function local:indice() as xs:integer* {
>
> for $i in (1 to 10)
> return $i
> };
>
> declare function local:nome() as xs:string* {
>
> for $n in ('a', 'b', 'c', 'd')
> return $n
> };
>
> for $indice at $pos in local:indice()
> for $nome in local:nome()[$pos]
>
> let $params:= <sql:parameters>
> <sql:parameter type="int">{$indice}</sql:parameter>
> <sql:parameter type="string">{$nome}</sql:parameter>
> </sql:parameters>
> return $params
>
>
> Regards, Max
>
> 2015-09-08 16:20 GMT+02:00 <michele.greco2(a)email.it>it>:
>> Hi i have following xquery:
>> declare function local:indice() as xs:integer* {
>> count(for $document in collection("curriculum")
>> let $c:= document-uri($document)
>> for $a in doc($c)
>> order by $c
>> return
>> for $e in doc($c)//w:tc[.//text()="Nome"]
>> return $e/./following::text()except
>> (for $x in doc($c)//w:tc[.//text()="Indirizzo"]
>> return $x//following::text()))
>> };
>>
>> declare function local:nome() as xs:string* {
>> for $document in collection("curriculum")
>> let $c:= document-uri($document)
>> for $a in doc($c)
>> order by $c
>> return
>> for $e in doc($c)//w:tc[.//text()="Nome"]
>> return $e/./following::text()except
>> (for $x in doc($c)//w:tc[.//text()="Indirizzo"]
>> return $x//following::text())
>> };
>> for $ indice in local:indice()
>> let $init := sql:init("com.mysql.jdbc.Driver"),
>> $conn :=
>>
sql:connect("jdbc:mysql://localhost:3306/DBName","user","password''),
>> $stmt := sql:prepare($conn, "INSERT INTO
>>
informazionipersonali(idInformazioniPersonali,nome,indirizzo,telefono,fax,email,nazionalità,dataNascita)
>> VALUES(?,?,'null','null','null','null','null','null') ")
>> for $nome in local:nome()
>> let $params:= <sql:parameters>
>> <sql:parameter type="int">{$indice}</sql:parameter>
>> <sql:parameter type="string">{$nome}</sql:parameter>
>> </sql:parameters>
>> return sql:execute-prepared($stmt,$params)
>>
>>
>> which return a combination of index and names, but i want only one
row for
>> each index and name.
>> How can i do?
>>
>> ----
>> ZE-Light e ZE-Pro: servizi zimbra per caselle con dominio
email.it, per
>> tutti i dettagli clicca qui
>>
>> Sponsor:
>> Registra i domini che desideri ed inizia a creare il tuo sito web
>> Clicca qui
----
ZE-Light e ZE-Pro: servizi zimbra per caselle con dominio email.it, per
tutti i dettagli clicca qui
Sponsor:
Soluzioni di email hosting per tutte le esigenze: dalle caselle gratuite a
quelle professionali su piattaforma Zimbra, da quelle su proprio dominio a
quelle certificate PEC. Confronta le soluzioni
Clicca qui
--
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_Zimbr…
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&d=10-9
Thanks for the help ,Max. I modified my xquery this way:
declare namespace pkg="http://schemas.microsoft.com/office/2006/xmlPackage";
declare namespace
w="http://schemas.openxmlformats.org/wordprocessingml/2006/main";
declare function local:indice() as xs:integer* {
for $i in(1 to count(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nome"]
return $e/./following::text()except
(for $x in doc($c)//w:tc[.//text()="Indirizzo"]
return $x//following::text())))
return $i
};
declare function local:nome() as xs:string* {
for $n in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nome"]
return $e/./following::text()except
(for $x in doc($c)//w:tc[.//text()="Indirizzo"]
return $x//following::text()))
return $n
};
declare function local:indirizzo() as xs:string* {
for $in in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Indirizzo"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="Telefono"]
return $x//following::text()))
return $in
};
declare function local:telefono() as xs:string* {
for $t in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Telefono"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="Fax"]
return $x//following::text()))
return $t
};
declare function local:fax() as xs:string* {
for $f in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Fax"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="E-mail"]
return $x//following::text()))
return $f
};
declare function local:email() as xs:string* {
for $em in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="E-mail"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="Nazionalità"]
return $x//following::text()))
return $em
};
declare function local:nazionalita() as xs:string* {
for $na in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nazionalità"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text() ="D" ]
return $x//following::text()))
return $na
};
declare function local:dataNascita() as xs:string* {
for $d in
(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Data di nascita"]
return $e/./following::text() except
(for $x in doc($c)//w:tc[.//text()="Esperienza lavorativa"]
return $x//following::text()))
return $d
};
for $indice at $pos in local:indice()
for $nome in local:nome() [$pos]
for $indirizzo in local:indirizzo()[$pos]
for $telefono in local:telefono()[$pos]
for $fax in local:fax()[$pos]
for $email in local:email()[$pos]
for $nazionalita in local:nazionalita()[$pos]
for $datanascita in local:dataNascita()[$pos]
let $init := sql:init("com.mysql.jdbc.Driver"),
$conn :=
sql:connect("jdbc:mysql://localhost:3306/DbName","user","password''),
$stmt := sql:prepare($conn, "INSERT INTO
informazionipersonali(idInformazioniPersonali,nome,indirizzo,telefono,fax,email,nazionalità,dataNascita)
VALUES(?,?,?,?,?,?,?,?) ")
let $params:= <sql:parameters>
<sql:parameter
type="int">{$indice}</sql:parameter>
<sql:parameter
type="string">{$nome}</sql:parameter>
<sql:parameter
type="string">{$indirizzo}</sql:parameter>
<sql:parameter
type="string">{$telefono}</sql:parameter>
<sql:parameter
type="string">{$fax}</sql:parameter>
<sql:parameter
type="string">{$email}</sql:parameter>
<sql:parameter
type="string">{$nazionalita}</sql:parameter>
<sql:parameter
type="string">{$datanascita}</sql:parameter>
</sql:parameters>
return sql:execute-prepared($stmt,$params)
It works,but it returns only the first row in my database, and i want a row
for each value (indice,nome,indirizzo,........)
How can i do?
--------- Original Message --------
Da: "Maximilian Gärber" <mgaerber(a)arcor.de>
To: "basex-talk(a)mailman.uni-konstanz.de"
<basex-talk(a)mailman.uni-konstanz.de>
Oggetto: Re: [basex-talk] problem with prepared
Data: 09/09/15 09:12
or using a where statement
for $indice at $pos in local:indice()
for $nome at $pos2 in local:nome()
let $params:= <sql:parameters>
<sql:parameter type="int">{$indice}</sql:parameter>
<sql:parameter type="string">{$nome}</sql:parameter>
</sql:parameters>
where $pos2 = $pos
return $params
2015-09-09 9:05 GMT+02:00 Maximilian Gärber <mgaerber(a)arcor.de>de>:
> Hi,
>
> when you join (by nesting for statements) you will always get the
> combinations unless you provide more constraints.
>
> You might try something like:
>
> declare function local:indice() as xs:integer* {
>
> for $i in (1 to 10)
> return $i
> };
>
> declare function local:nome() as xs:string* {
>
> for $n in ('a', 'b', 'c', 'd')
> return $n
> };
>
> for $indice at $pos in local:indice()
> for $nome in local:nome()[$pos]
>
> let $params:= <sql:parameters>
> <sql:parameter type="int">{$indice}</sql:parameter>
> <sql:parameter type="string">{$nome}</sql:parameter>
> </sql:parameters>
> return $params
>
>
> Regards, Max
>
> 2015-09-08 16:20 GMT+02:00 <michele.greco2(a)email.it>it>:
>> Hi i have following xquery:
>> declare function local:indice() as xs:integer* {
>> count(for $document in collection("curriculum")
>> let $c:= document-uri($document)
>> for $a in doc($c)
>> order by $c
>> return
>> for $e in doc($c)//w:tc[.//text()="Nome"]
>> return $e/./following::text()except
>> (for $x in doc($c)//w:tc[.//text()="Indirizzo"]
>> return $x//following::text()))
>> };
>>
>> declare function local:nome() as xs:string* {
>> for $document in collection("curriculum")
>> let $c:= document-uri($document)
>> for $a in doc($c)
>> order by $c
>> return
>> for $e in doc($c)//w:tc[.//text()="Nome"]
>> return $e/./following::text()except
>> (for $x in doc($c)//w:tc[.//text()="Indirizzo"]
>> return $x//following::text())
>> };
>> for $ indice in local:indice()
>> let $init := sql:init("com.mysql.jdbc.Driver"),
>> $conn :=
>>
sql:connect("jdbc:mysql://localhost:3306/DBName","user","password''),
>> $stmt := sql:prepare($conn, "INSERT INTO
>>
informazionipersonali(idInformazioniPersonali,nome,indirizzo,telefono,fax,email,nazionalità,dataNascita)
>> VALUES(?,?,'null','null','null','null','null','null') ")
>> for $nome in local:nome()
>> let $params:= <sql:parameters>
>> <sql:parameter type="int">{$indice}</sql:parameter>
>> <sql:parameter type="string">{$nome}</sql:parameter>
>> </sql:parameters>
>> return sql:execute-prepared($stmt,$params)
>>
>>
>> which return a combination of index and names, but i want only one
row for
>> each index and name.
>> How can i do?
>>
>> ----
>> ZE-Light e ZE-Pro: servizi zimbra per caselle con dominio
email.it, per
>> tutti i dettagli clicca qui
>>
>> Sponsor:
>> Registra i domini che desideri ed inizia a creare il tuo sito web
>> Clicca qui
--
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_Zimbr…
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&d=10-9
Hi i have following xquery:
declare function local:indice() as xs:integer* {
count(for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nome"]
return $e/./following::text()except
(for $x in doc($c)//w:tc[.//text()="Indirizzo"]
return $x//following::text()))
};
declare function local:nome() as xs:string* {
for $document in collection("curriculum")
let $c:= document-uri($document)
for $a in doc($c)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nome"]
return $e/./following::text()except
(for $x in doc($c)//w:tc[.//text()="Indirizzo"]
return $x//following::text())
};
for $ indice in local:indice()
let $init := sql:init("com.mysql.jdbc.Driver"),
$conn :=
sql:connect("jdbc:mysql://localhost:3306/DBName","user","password''),
$stmt := sql:prepare($conn, "INSERT INTO
informazionipersonali(idInformazioniPersonali,nome,indirizzo,telefono,fax,email,nazionalità,dataNascita)
VALUES(?,?,'null','null','null','null','null','null') ")
for $nome in local:nome()
let $params:= <sql:parameters>
<sql:parameter
type="int">{$indice}</sql:parameter>
<sql:parameter
type="string">{$nome}</sql:parameter>
</sql:parameters>
return sql:execute-prepared($stmt,$params)
which return a combination of index and names, but i want only one row for
each index and name.
How can i do?
--
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_Zimbr…
Sponsor:
Registra i domini che desideri ed inizia a creare il tuo sito web
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13323&d=8-9
Hi, i have tihsi error :[bxerr:BXSQ0003] Number of parameters differs from
number of placeholders in this xquery:
declare namespace
w="http://schemas.openxmlformats.org/wordprocessingml/2006/main";
declare function local:nome() as xs:string* {
for $document in collection("curriculum")
let $c:= document-uri($document)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nome"]
return $e/./following::text() except (
for $x in doc($c)//w:tc[.//text()="Indirizzo"]
return $x//following::text())
};
let $init := sql:init("com.mysql.jdbc.Driver"),
$conn :=
sql:connect("jdbc:mysql://localhost:3306/DbName","user","password"),
$stmt := sql:prepare($conn, "INSERT INTO person
VALUES('',?,'','','','','')")
for $nome in local:nome()
return sql:ute-prepared($stmt,
<sql:parameters>
<sql:parameter type="string">{$nome}</sql:parameter>
</sql:parameters>)
Why?
--
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_Zimbr…
Sponsor:
Soluzioni di email hosting per tutte le esigenze: dalle caselle gratuite a quelle professionali su piattaforma Zimbra, da quelle su proprio dominio a quelle certificate PEC. Confronta le soluzioni
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13326&d=7-9
Hi thanks for help me.
Now, i have the following error:
[bxerr:BXSQ0003] Number of parameters differs from number of placeholders
What can i do to solve it?
--------- Original Message --------
Da: "Dimitar Popov" <dp(a)basex.org>
To: "basex-talk(a)mailman.uni-konstanz.de"
<basex-talk(a)mailman.uni-konstanz.de>
Oggetto: Re: [basex-talk] sql error
Data: 05/09/15 21:56
On Saturday, September 05, 2015 10:13:08 AM michele.greco2(a)email.it wrote:
> Hi,
Hi!
> where am i wrong?
1. you have an XQuery syntax error; instead of:
let $q:= "insert into person values("","||nome||","","","","","","")"
it should be (note the different quotation marks):
let $q:= "insert into person values(''," || $nome || ",'','','','','','')"
2. you have SQL injection [1] and performance issue by concatenating the
value directly into the SQL statement; prepared statements [2] are in this
case your friend:
declare namespace
w="http://schemas.openxmlformats.org/wordprocessingml/2006/main";
declare function local:nome() as xs:string* {
(: I've no idea whatcha doin here pal... :)
for $document in collection("curriculum")
let $c:= document-uri($document)
order by $c
return
for $e in doc($c)//w:tc[.//text()="Nome"]
return $e/./following::text() except (
for $x in doc($c)//w:tc[.//text()="Indirizzo"]
return $x//following::text())
};
let $init := sql:init("com.mysql.jdbc.Driver"),
$conn :=
sql:connect("jdbc:mysql://localhost:3306/DbName","user","password"),
$stmt := sql:prepare($conn, "INSERT INTO person
VALUES('',?,'','','','','')")
for $nome in local:nome()
return sql:execute-prepared($stmt,
<sql:parameters>
<sql:parameter type="string">{$nome}</sql:parameter>
</sql:parameters>)
Check the BaseX docs [3] for more info and come back if you need more help
:)
Cheers,
Dimitar
[1] https://en.wikipedia.org/wiki/Sql_injection
[2] https://en.wikipedia.org/wiki/Prepared_statement
[3] http://docs.basex.org/wiki/SQL_Module
--
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_Zimbr…
Sponsor:
Soluzioni di email hosting per tutte le esigenze: dalle caselle gratuite a quelle professionali su piattaforma Zimbra, da quelle su proprio dominio a quelle certificate PEC. Confronta le soluzioni
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13325&d=7-9
Hi,
I wrote this xquery,who want to save the query result in myql.
declare namespace pkg="http://schemas.microsoft.com/office/2006/xmlPackage";
declare namespace
w="http://schemas.openxmlformats.org/wordprocessingml/2006/main";
sql:init("com.mysql.jdbc.Driver"),
let $conn:=
sql:connect("jdbc:mysql://localhost:3306/DbName","user","password")
return
(let $q:= "insert into person values("","||nome||","","","","","","")"
return sql:execute($conn,$q)),
for $document in collection("curriculum")
let $c:= document-uri($document)
order by $c
return <nome>
{for $e in doc($c)//w:tc[.//text()="Nome"]
return $e/./following::text()except
(for $x in doc($c)//w:tc[.//text()="Indirizzo"]
return $x//following::text())
}</nome>
but this is my error:
[XPDY0002] nome: no context value bound.
where am i wrong?
--
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_Zimbr…
Sponsor:
Registra i domini che desideri ed inizia a creare il tuo sito web
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13323&d=5-9
James, you are right, OPTIMIZE ALL solves the problem.
The txt.basex was growing at each replace, other files staying almost
identical.
Thanks a lot !
Best regards,
Christophe
Le 03/09/2015 21:20, basex-talk-request(a)mailman.uni-konstanz.de a écrit :
> Send BaseX-Talk mailing list submissions to
> basex-talk(a)mailman.uni-konstanz.de
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
> or, via email, send a message with subject or body 'help' to
> basex-talk-request(a)mailman.uni-konstanz.de
>
> You can reach the person managing the list at
> basex-talk-owner(a)mailman.uni-konstanz.de
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of BaseX-Talk digest..."
>
>
> Today's Topics:
>
> 1. Xquery collections (michele.greco2(a)email.it)
> 2. Re: Xquery collections (Dirk Kirsten)
> 3. Re: size on collection in the time (Marc)
> 4. Re: size on collection in the time (Christophe Marchand)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 3 Sep 2015 17:48:23 +0200
> From: michele.greco2(a)email.it
> To: basex-talk(a)mailman.uni-konstanz.de
> Subject: [basex-talk] Xquery collections
> Message-ID: <22e8f2f70298a35093e933ab65f26489(a)wm10.email.it>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
> 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_Zimbr…
>
> 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&d=3-9
>
James, you are right, OPTIMIZE ALL solves the problem.
Thanks a lot !
Best regards,
Christophe
Le 03/09/2015 21:20, basex-talk-request(a)mailman.uni-konstanz.de a écrit :
> Send BaseX-Talk mailing list submissions to
> basex-talk(a)mailman.uni-konstanz.de
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
> or, via email, send a message with subject or body 'help' to
> basex-talk-request(a)mailman.uni-konstanz.de
>
> You can reach the person managing the list at
> basex-talk-owner(a)mailman.uni-konstanz.de
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of BaseX-Talk digest..."
>
>
> Today's Topics:
>
> 1. Xquery collections (michele.greco2(a)email.it)
> 2. Re: Xquery collections (Dirk Kirsten)
> 3. Re: size on collection in the time (Marc)
> 4. Re: size on collection in the time (Christophe Marchand)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 3 Sep 2015 17:48:23 +0200
> From: michele.greco2(a)email.it
> To: basex-talk(a)mailman.uni-konstanz.de
> Subject: [basex-talk] Xquery collections
> Message-ID: <22e8f2f70298a35093e933ab65f26489(a)wm10.email.it>
> Content-Type: text/plain; charset="iso-8859-1"
>
>
> 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_Zimbr…
>
> 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&d=3-9
>
Hi Dirk,
attached a simple test-case to reproduce the problem.
data.xml is a file that contains attributes and text. Each time you run
run.sh, data.xml is re-created, with current-dateTime() in. So each
time, the file content is changed.
The file size does not change (date format ensures it).
reload.bxs deletes the file from the collection and add it back to the
collection.
run.sh displays the size of files in the collection.
Each time you start run.sh, file size grows.
You need to modify run.sh to set the correct directories locations.
You have to add saxon9he.jar to run it.
I hope this will help,
Christophe
Le 03/09/2015 15:27, basex-talk-request(a)mailman.uni-konstanz.de a écrit :
> Send BaseX-Talk mailing list submissions to
> basex-talk(a)mailman.uni-konstanz.de
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
> or, via email, send a message with subject or body 'help' to
> basex-talk-request(a)mailman.uni-konstanz.de
>
> You can reach the person managing the list at
> basex-talk-owner(a)mailman.uni-konstanz.de
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of BaseX-Talk digest..."
>
>
> Today's Topics:
>
> 1. Re: size on collection in the time (Marc) (cmarchand(a)oxiane.com)
> 2. Re: Unexpected error: Improper use? Potential bug?
> (Pierre-Yves JALLUD)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 03 Sep 2015 14:59:53 +0200
> From: cmarchand(a)oxiane.com
> To: basex-talk(a)mailman.uni-konstanz.de
> Subject: Re: [basex-talk] size on collection in the time (Marc)
> Message-ID: <2fe47eb3ff5f77da91888afed19d2d72(a)oxiane.com>
> Content-Type: text/plain; charset="us-ascii"
>
>
>
> I confirm the problem : on another database (same data, same script.xbs,
> different server), we have exactly the same problem : the database grows
> each time the script is run.
>
> I'm going to prepare a test-case with small public data tonight.
>
> Best regards,
>
> Christophe
>
> 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
> ------------------------------
>
> Message: 4
> Date: Thu, 3 Sep 2015 10:01:05 +0200
> From: Marc <Marc.Liste(a)free.fr>
> To: Dirk Kirsten <dk(a)basex.org>
> Cc: BaseX <basex-talk(a)mailman.uni-konstanz.de>
> Subject: Re: [basex-talk] (no subject)
> Message-ID: <55E7FE41.5080205(a)free.fr>
> Content-Type: text/plain; charset=iso-8859-15; format=flowed
>
> 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
> End of BaseX-Talk Digest, Vol 69, Issue 5
> *****************************************
>