From christian.gruen at gmail.com Tue Jul 5 05:25:08 2016 From: christian.gruen at gmail.com (=?UTF-8?Q?Christian_Gr=C3=BCn?=) Date: Tue, 5 Jul 2016 14:25:08 +0200 Subject: [xquery-talk] [ANN] BaseX 8.5: The Summer Edition Message-ID: Dear all, A new Summer Edition of BaseX is available! Our XML database system and XQuery 3.1 processor provides the following new stunning features: DATABASE JOBS - all registered database jobs are now centrally administered - jobs can be scheduled (periodical execution, start/end time) - job results can be cached and retrieved later on - new Jobs Module: XQuery functions for managing jobs - new commands: JOBS [LIST|RESULT|STOP] - DBA: visualization of currently registered jobs XQUERY - parallel execution via xquery:fork-join (thank you, James Wright!) - alignments with the latest changes in the XQuery 3.1 specification - easy chaining of update operations with the 'update' keyword - numerous optimizations, smarter rewritings and heuristics XQUERY MODULES - File, Conversion, Fetch Module: handling of invalid XML characters - Inspection Module: inspect:function-annotations added OPTIONS - LOGPATH: custom path for logging data - CACHETIMEOUT: timeout for dropping cached job results - AUTHMETHOD: `custom` added to skip authentication Visit http://basex.org to find the latest release, and check out http://docs.basex.org/ to get more information. Have fun, Christian BaseX Team From alex.g.muir at gmail.com Wed Jul 6 02:10:11 2016 From: alex.g.muir at gmail.com (Alex Muir) Date: Wed, 6 Jul 2016 09:10:11 +0000 Subject: [xquery-talk] How do I insert a node as first element within a for loop? Message-ID: Greetings, Running in Basex I get the following error: XUST0001 element constructor: no updating expression allowed. When trying to insert *insert nodes test as first into $c* I feel like my code is following the examples I see online although clearly I've got something wrong. How do I insert a node with a for loop? declare namespace db="http://basex.org/modules/db"; declare namespace file="http://expath.org/ns/file"; declare variable $form13FFileNumber as xs:string external; let $data := db:open('13F')//data[contains(edgarSubmission/formData/coverPage/form13FFileNumber,$form13FFileNumber)] let $fields := { for $c in $data return insert nodes test as first into $c } return file:write(concat('../OUT/' , $form13FFileNumber , '.xml'), $fields) To be more clear my xml looks something like text text and I would like it to adjust to test text test text Regards Alex tech.jahtoe.com bafila.jahtoe.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From g at 28.io Wed Jul 6 02:19:48 2016 From: g at 28.io (Ghislain Fourny) Date: Wed, 6 Jul 2016 11:19:48 +0200 Subject: [xquery-talk] How do I insert a node as first element within a for loop? In-Reply-To: References: Message-ID: Hi Alex, You can either use a query, or updates. Your query mixes both, which is why you are getting an error, as updates can't be nested in expressions that produce items. In your case though, since you need to modify the top-level, a query makes most sense, and the good news is it's really simple. ... let $fields := { $data } ... Then you can replace the file with the results of the query as you do with file:write. If you really want to update, you can do something like: replace node $data with { $data } but then you can't use the file:write machinery and need to rely on the underlying engine to do the edit in place. In the more general case where you need to edit plenty of places in your document, you can use the copy-modify-return expression. It's very handy to create an updated copy. I hope it helps! Kind regards, Ghislain On Wed, Jul 6, 2016 at 11:10 AM, Alex Muir wrote: > > > Greetings, > > Running in Basex I get the following error: > > XUST0001 element constructor: no updating expression allowed. > > When trying to insert insert nodes test as first into $c > > I feel like my code is following the examples I see online although clearly I've got something wrong. > > How do I insert a node with a for loop? > > declare namespace db="http://basex.org/modules/db"; > declare namespace file="http://expath.org/ns/file"; > declare variable $form13FFileNumber as xs:string external; > > let $data := db:open('13F')//data[contains(edgarSubmission/formData/coverPage/form13FFileNumber,$form13FFileNumber)] > > let $fields := > > > { > for $c in $data return > insert nodes test as first into $c > } > > > return file:write(concat('../OUT/' , $form13FFileNumber , '.xml'), $fields) > > To be more clear my xml looks something like > > > text > > > text > > > and I would like it to adjust to > > > > test > text > > > test > text > > > > > > Regards > Alex > tech.jahtoe.com > bafila.jahtoe.com > > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk -------------- next part -------------- An HTML attachment was scrubbed... URL: From g at 28.io Wed Jul 6 02:22:44 2016 From: g at 28.io (Ghislain Fourny) Date: Wed, 6 Jul 2016 11:22:44 +0200 Subject: [xquery-talk] How do I insert a node as first element within a for loop? In-Reply-To: References: Message-ID: Hi Alex, Me again. I read through your expected result too fast and missed the b4 part :-) So indeed you need a copy modify: ... let $fields := { for $c in $data return copy $new-node := $c modify insert nodes test as first into $new-node return $new-node } ... I hope I got it right this time! Kind regards, Ghislain On Wed, Jul 6, 2016 at 11:19 AM, Ghislain Fourny wrote: > > Hi Alex, > > You can either use a query, or updates. Your query mixes both, which is why you are getting an error, as updates can't be nested in expressions that produce items. > > In your case though, since you need to modify the top-level, a query makes most sense, and the good news is it's really simple. > > ... > let $fields := > { > $data > } > ... > > Then you can replace the file with the results of the query as you do with file:write. > > If you really want to update, you can do something like: > > replace node $data with > { > $data > } > > but then you can't use the file:write machinery and need to rely on the underlying engine to do the edit in place. > > In the more general case where you need to edit plenty of places in your document, you can use the copy-modify-return expression. It's very handy to create an updated copy. > > I hope it helps! > > Kind regards, > Ghislain > > > > On Wed, Jul 6, 2016 at 11:10 AM, Alex Muir wrote: > > > > > > Greetings, > > > > Running in Basex I get the following error: > > > > XUST0001 element constructor: no updating expression allowed. > > > > When trying to insert insert nodes test as first into $c > > > > I feel like my code is following the examples I see online although clearly I've got something wrong. > > > > How do I insert a node with a for loop? > > > > declare namespace db="http://basex.org/modules/db"; > > declare namespace file="http://expath.org/ns/file"; > > declare variable $form13FFileNumber as xs:string external; > > > > let $data := db:open('13F')//data[contains(edgarSubmission/formData/coverPage/form13FFileNumber,$form13FFileNumber)] > > > > let $fields := > > > > > > { > > for $c in $data return > > insert nodes test as first into $c > > } > > > > > > return file:write(concat('../OUT/' , $form13FFileNumber , '.xml'), $fields) > > > > To be more clear my xml looks something like > > > > > > text > > > > > > text > > > > > > and I would like it to adjust to > > > > > > > > test > > text > > > > > > test > > text > > > > > > > > > > > > Regards > > Alex > > tech.jahtoe.com > > bafila.jahtoe.com > > > > _______________________________________________ > > talk at x-query.com > > http://x-query.com/mailman/listinfo/talk -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.g.muir at gmail.com Wed Jul 6 02:27:48 2016 From: alex.g.muir at gmail.com (Alex Muir) Date: Wed, 6 Jul 2016 09:27:48 +0000 Subject: [xquery-talk] How do I insert a node as first element within a for loop? In-Reply-To: References: Message-ID: Hi Ghislain, That worked! Cheers! Regards Alex tech.jahtoe.com bafila.jahtoe.com On Wed, Jul 6, 2016 at 9:22 AM, Ghislain Fourny wrote: > Hi Alex, > > Me again. I read through your expected result too fast and missed the b4 > part :-) > > So indeed you need a copy modify: > > ... > let $fields := > > { > for $c in $data > return > copy $new-node := $c > modify insert nodes test as first into $new-node > return $new-node > } > > ... > > I hope I got it right this time! > > Kind regards, > Ghislain > > > On Wed, Jul 6, 2016 at 11:19 AM, Ghislain Fourny wrote: > > > > Hi Alex, > > > > You can either use a query, or updates. Your query mixes both, which is > why you are getting an error, as updates can't be nested in expressions > that produce items. > > > > In your case though, since you need to modify the top-level, a query > makes most sense, and the good news is it's really simple. > > > > ... > > let $fields := > > { > > $data > > } > > ... > > > > Then you can replace the file with the results of the query as you do > with file:write. > > > > If you really want to update, you can do something like: > > > > replace node $data with > > { > > $data > > } > > > > but then you can't use the file:write machinery and need to rely on the > underlying engine to do the edit in place. > > > > In the more general case where you need to edit plenty of places in your > document, you can use the copy-modify-return expression. It's very handy to > create an updated copy. > > > > I hope it helps! > > > > Kind regards, > > Ghislain > > > > > > > > On Wed, Jul 6, 2016 at 11:10 AM, Alex Muir > wrote: > > > > > > > > > Greetings, > > > > > > Running in Basex I get the following error: > > > > > > XUST0001 element constructor: no updating expression allowed. > > > > > > When trying to insert insert nodes test as first into $c > > > > > > I feel like my code is following the examples I see online although > clearly I've got something wrong. > > > > > > How do I insert a node with a for loop? > > > > > > declare namespace db="http://basex.org/modules/db"; > > > declare namespace file="http://expath.org/ns/file"; > > > declare variable $form13FFileNumber as xs:string external; > > > > > > let $data := > db:open('13F')//data[contains(edgarSubmission/formData/coverPage/form13FFileNumber,$form13FFileNumber)] > > > > > > let $fields := > > > > > > > > > { > > > for $c in $data return > > > insert nodes test as first into $c > > > } > > > > > > > > > return file:write(concat('../OUT/' , $form13FFileNumber , '.xml'), > $fields) > > > > > > To be more clear my xml looks something like > > > > > > > > > text > > > > > > > > > text > > > > > > > > > and I would like it to adjust to > > > > > > > > > > > > test > > > text > > > > > > > > > test > > > text > > > > > > > > > > > > > > > > > > Regards > > > Alex > > > tech.jahtoe.com > > > bafila.jahtoe.com > > > > > > _______________________________________________ > > > talk at x-query.com > > > http://x-query.com/mailman/listinfo/talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: