Re: [basex-talk] how to declare an updating function parameter in a high-order function signature ?

2018-02-06 Thread Fabrice ETANCHAUD
Thank you Christian.

There is something faster than BaseX : its support !

Best regards,

-Message d'origine-
De : Christian Grün [mailto:christian.gr...@gmail.com] 
Envoyé : mardi 6 février 2018 15:44
À : Fabrice ETANCHAUD
Cc : basex-talk@mailman.uni-konstanz.de
Objet : Re: [basex-talk] how to declare an updating function parameter in a 
high-order function signature ?

Hi Fabrice,

I believe it should be sufficient to prepend the "updating" keyword before your 
function call [1]:

  updating $builder(...)

Greetings from the (yes, currently) sunny Lake Constance, Christian

[1] http://docs.basex.org/wiki/XQuery_Update#User-Defined_Functions



On Tue, Feb 6, 2018 at 3:37 PM, Fabrice ETANCHAUD  
wrote:
> Dear all,
>
>
>
> I cannot find a way to tell the xquey engine that a function parameter 
> of my high-order function is updating :
>
>
>
> declare %updating function etebac:build-updating($file as xs:string, 
> $builder as %updating function(*) ) {
>
>   for tumbling window $line in (file:read-text-lines($file))
>
>   start $start-item when etebac:record-header($start-item) = '01'
>
>   end $end-item when etebac:record-header($end-item) = '07'
>
>   let $doc := etebac:build-json($line)
>
>   let $start := format-date(xs:date($doc/date-ancien-solde),
> '[Y0001][M01][D01]')
>
>   let $stop := format-date(xs:date($doc/date), '[Y0001][M01][D01]')
>
>   let $doc-id := string-join(($doc/rib, $start, $stop), '-')
>
>   let $doc-path := string-join(
>
> ($doc/(banque, guichet, compte), $start || '-' || $stop), '/')
>
>   let $out-file := concat($doc-path, '.json')
>
>   where count($doc/operations/_) > 0
>
>   return
>
> $builder(
>
>   $doc-path,
>
>   element json {
>
> attribute type { 'object' },
>
> element meta {
>
>   attribute type { 'object' },
>
>   element type { 'releve-operations' },
>
>   element id { $doc-id }
>
> },
>
> element data {
>
>   $doc/(*|@*)
>
> }
>
>   }
>
>)
>
> };
>
>
>
> I have a [XPTY0004] Function must not be updating: %updating
> function($path,$doc) a... error.
>
>
>
> The outer call is  :
>
>
>
> import module namespace etebac =
> 'http://pch.cerfrance.fr/basex/modules/etebac' at 'etebac.xqm';
>
>
>
> etebac:build-updating('D:\edi\banque\input\10278\10278_CMLACO_20160701
> .183',
>
> db:replace('test', ?, ?)
>
> )
>
>
>
> What have I to do to tag my $builder function reference as updating in 
> the main body ?
>
>
>
> Best regards from the snowy french atlantic coast,
>
> Fabrice


Re: [basex-talk] how to declare an updating function parameter in a high-order function signature ?

2018-02-06 Thread Christian Grün
Hi Fabrice,

I believe it should be sufficient to prepend the "updating" keyword
before your function call [1]:

  updating $builder(...)

Greetings from the (yes, currently) sunny Lake Constance,
Christian

[1] http://docs.basex.org/wiki/XQuery_Update#User-Defined_Functions



On Tue, Feb 6, 2018 at 3:37 PM, Fabrice ETANCHAUD
 wrote:
> Dear all,
>
>
>
> I cannot find a way to tell the xquey engine that a function parameter of my
> high-order function is updating :
>
>
>
> declare %updating function etebac:build-updating($file as xs:string,
> $builder as %updating function(*) ) {
>
>   for tumbling window $line in (file:read-text-lines($file))
>
>   start $start-item when etebac:record-header($start-item) = '01'
>
>   end $end-item when etebac:record-header($end-item) = '07'
>
>   let $doc := etebac:build-json($line)
>
>   let $start := format-date(xs:date($doc/date-ancien-solde),
> '[Y0001][M01][D01]')
>
>   let $stop := format-date(xs:date($doc/date), '[Y0001][M01][D01]')
>
>   let $doc-id := string-join(($doc/rib, $start, $stop), '-')
>
>   let $doc-path := string-join(
>
> ($doc/(banque, guichet, compte), $start || '-' || $stop), '/')
>
>   let $out-file := concat($doc-path, '.json')
>
>   where count($doc/operations/_) > 0
>
>   return
>
> $builder(
>
>   $doc-path,
>
>   element json {
>
> attribute type { 'object' },
>
> element meta {
>
>   attribute type { 'object' },
>
>   element type { 'releve-operations' },
>
>   element id { $doc-id }
>
> },
>
> element data {
>
>   $doc/(*|@*)
>
> }
>
>   }
>
>)
>
> };
>
>
>
> I have a [XPTY0004] Function must not be updating: %updating
> function($path,$doc) a... error.
>
>
>
> The outer call is  :
>
>
>
> import module namespace etebac =
> 'http://pch.cerfrance.fr/basex/modules/etebac' at 'etebac.xqm';
>
>
>
> etebac:build-updating('D:\edi\banque\input\10278\10278_CMLACO_20160701.183',
>
> db:replace('test', ?, ?)
>
> )
>
>
>
> What have I to do to tag my $builder function reference as updating in the
> main body ?
>
>
>
> Best regards from the snowy french atlantic coast,
>
> Fabrice


[basex-talk] how to declare an updating function parameter in a high-order function signature ?

2018-02-06 Thread Fabrice ETANCHAUD
Dear all,

I cannot find a way to tell the xquey engine that a function parameter of my 
high-order function is updating :

declare %updating function etebac:build-updating($file as xs:string, $builder 
as %updating function(*) ) {
  for tumbling window $line in (file:read-text-lines($file))
  start $start-item when etebac:record-header($start-item) = '01'
  end $end-item when etebac:record-header($end-item) = '07'
  let $doc := etebac:build-json($line)
  let $start := format-date(xs:date($doc/date-ancien-solde), 
'[Y0001][M01][D01]')
  let $stop := format-date(xs:date($doc/date), '[Y0001][M01][D01]')
  let $doc-id := string-join(($doc/rib, $start, $stop), '-')
  let $doc-path := string-join(
($doc/(banque, guichet, compte), $start || '-' || $stop), '/')
  let $out-file := concat($doc-path, '.json')
  where count($doc/operations/_) > 0
  return
$builder(
  $doc-path,
  element json {
attribute type { 'object' },
element meta {
  attribute type { 'object' },
  element type { 'releve-operations' },
  element id { $doc-id }
},
element data {
  $doc/(*|@*)
}
  }
   )
};

I have a [XPTY0004] Function must not be updating: %updating 
function($path,$doc) a... error.

The outer call is  :

import module namespace etebac = 'http://pch.cerfrance.fr/basex/modules/etebac' 
at 'etebac.xqm';

etebac:build-updating('D:\edi\banque\input\10278\10278_CMLACO_20160701.183',
db:replace('test', ?, ?)
)

What have I to do to tag my $builder function reference as updating in the main 
body ?

Best regards from the snowy french atlantic coast,
Fabrice