~paul-lucas/zorba/bug-932374

« back to all changes in this revision

Viewing changes to modules/com/zorba-xquery/www/modules/store/dynamic/collections/dml.xq

  • Committer: Paul J. Lucas
  • Date: 2012-09-21 20:26:47 UTC
  • mfrom: (10819.2.235 zorba)
  • Revision ID: paul@lucasmail.org-20120921202647-fy9n4jduhrnljrnb
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
:)
18
18
 
19
19
(:~
20
 
 : This modules provides a set of functions to modify a collection and retrieve the nodes
 
20
 : This modules provides a set of functions to modify a collection and retrieve the items
21
21
 : contained in a particular collection.
22
22
 :
23
23
 : <p>Please refer to our documentation for <a href="../../html/data_lifecycle.html">
40
40
declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
41
41
declare option ver:module-version "2.0";
42
42
 
 
43
 
43
44
(:~
44
45
 : The insert-nodes-first function is an updating function that inserts copies of the
45
46
 : given nodes at the beginning of the collection.
52
53
 :
53
54
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
54
55
 :
55
 
 :)
56
 
declare updating function dml:insert-nodes-first(
57
 
  $name as xs:QName,
58
 
  $content as node()*) external;
 
56
 : @deprecated please use the cdml:insert-first#2 function
 
57
 :
 
58
 :)
 
59
declare updating function 
 
60
dml:insert-nodes-first($name as xs:QName, $content as node()*) external;
 
61
 
 
62
 
 
63
(:~
 
64
 : The insert-first function is an updating function that inserts copies of the
 
65
 : given items (nodes or json items) at the beginning of the collection.
 
66
 :
 
67
 : @param $name The name of the collection to which the items should be added.
 
68
 : @param $content The sequences of items whose copies should be added to the collection.
 
69
 :
 
70
 : @return The result of the function is an empty XDM instance and a pending update
 
71
 :         list which, once applied, inserts the items into the collection.
 
72
 :
 
73
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
 
74
 :
 
75
 :)
 
76
declare updating function 
 
77
dml:insert-first($name as xs:QName, $content as item()*) external;
 
78
 
59
79
 
60
80
(:~
61
81
 : The insert-nodes-last function is an updating function that inserts copies of the
69
89
 :
70
90
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
71
91
 :
72
 
 :)
73
 
declare updating function dml:insert-nodes-last(
74
 
  $name as xs:QName,
75
 
  $content as node()*) external;
 
92
 : @deprecated please use the cdml:insert-last#2 function
 
93
 :
 
94
 :)
 
95
declare updating function 
 
96
dml:insert-nodes-last($name as xs:QName, $content as node()*) external;
 
97
 
 
98
 
 
99
(:~
 
100
 : The insert-last function is an updating function that inserts copies of the
 
101
 : given items (nodes or json items) at the end of the collection.
 
102
 :
 
103
 : @param $name The name of the collection to which the items should  be added.
 
104
 : @param $content The sequences of items whose copies should be added to the collection.
 
105
 :
 
106
 : @return The result of the function is an empty XDM instance and a pending update list
 
107
 :         which, once applied, inserts the items into the collection.
 
108
 :
 
109
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
 
110
 :
 
111
 :)
 
112
declare updating function 
 
113
dml:insert-last($name as xs:QName, $content as item()*) external;
 
114
 
76
115
 
77
116
(:~
78
117
 : The insert-nodes-before function is an updating function that inserts
90
129
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
91
130
 : @error zerr:ZDDY0011 if the target node is not contained in the collection.
92
131
 :
 
132
 : @deprecated please use the cdml:insert-before#3 function
 
133
 :
93
134
 :)
94
 
declare updating function dml:insert-nodes-before(
 
135
declare updating function 
 
136
dml:insert-nodes-before(
95
137
  $name as xs:QName,
96
138
  $target as node(),
97
139
  $content as node()*) external;
98
140
 
99
141
(:~
 
142
 : The insert-before function is an updating function that inserts copies of
 
143
 : the given items (nodes or json items) into a collection at the position 
 
144
 : directly preceding the given target item.
 
145
 :
 
146
 : @param $name The name of the collection to which the items should  be added.
 
147
 : @param $target The item in the collection before which the $content
 
148
 :        sequence should be inserted.
 
149
 : @param $content The sequences of items whose copies should be added to the collection.
 
150
 :
 
151
 : @return The result of the function is an empty XDM instance and a pending update list
 
152
 :         which, once applied, inserts the items into the collection.
 
153
 :
 
154
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
 
155
 : @error zerr:ZDDY0011 if the target item is not contained in the collection.
 
156
 :
 
157
 :)
 
158
declare updating function 
 
159
dml:insert-before($name as xs:QName, $target as item(), $content as item()*) external;
 
160
 
 
161
 
 
162
(:~
100
163
 : The insert-nodes-after function is an updating function that inserts
101
164
 : copies of the given nodes into a collection at the position directly following the
102
165
 : given target node.
112
175
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
113
176
 : @error zerr:ZDDY0011 if the target node is not contained in the collection.
114
177
 :
 
178
 : @deprecated please use the cdml:insert-after#3 function
 
179
 :
115
180
 :)
116
 
declare updating function dml:insert-nodes-after(
 
181
declare updating function 
 
182
dml:insert-nodes-after(
117
183
  $name as xs:QName,
118
184
  $pos as node(),
119
185
  $content as node()*) external;
120
186
 
121
 
(:~
122
 
 : This function does the same as the insert-nodes function except
 
187
 
 
188
(:~
 
189
 : The insert-after function is an updating function that inserts copies of
 
190
 : the given items (nodes and/or json items) into a collection at the position
 
191
 : directly following the given target item.
 
192
 :
 
193
 : @param $name The name of the collection to which the items should be added.
 
194
 : @param $target The item in the collection after which the $content
 
195
 :        sequence should be inserted.
 
196
 : @param $content The sequences of items whose copies should be added to the collection.
 
197
 :
 
198
 : @return The result of the function is an empty XDM instance and a pending update list
 
199
 :         which, once applied, inserts the items into the collection.
 
200
 :
 
201
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
 
202
 : @error zerr:ZDDY0011 if the target node is not contained in the collection.
 
203
 :
 
204
 :)
 
205
declare updating function 
 
206
dml:insert-after($name as xs:QName, $pos as item(), $content as item()*) external;
 
207
 
 
208
 
 
209
(:~
 
210
 : This function does the same as the insert-nodes-first function except
123
211
 : it immediately applies the resulting pending updates and returns the
124
212
 : nodes that have been inserted.
125
213
 :
133
221
 :
134
222
 : @see dml:insert-nodes-first
135
223
 :
 
224
 : @deprecated please use the cdml:apply-insert-first#2 function
 
225
 :
136
226
 :)
137
 
declare %an:sequential function dml:apply-insert-nodes-first(
 
227
declare %an:sequential function 
 
228
dml:apply-insert-nodes-first(
138
229
  $name as xs:QName,
139
230
  $content as node()*) as node()* external;
140
231
 
 
232
 
 
233
(:~
 
234
 : This function does the same as the insert-first function except it immediately
 
235
 : applies the resulting pending updates and returns the items that have been inserted.
 
236
 :
 
237
 : @param $name The name of the collection to which the items should be added.
 
238
 : @param $content The sequences of items whose copies should be added to the collection.
 
239
 :
 
240
 : @return The result of the function is the sequence of items that have been
 
241
 :         inserted into the collection.
 
242
 :
 
243
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
 
244
 :
 
245
 : @see dml:insert-first
 
246
 :
 
247
 :)
 
248
declare %an:sequential function 
 
249
dml:apply-insert-first($name as xs:QName, $content as item()*) as item()* external;
 
250
 
 
251
 
141
252
(:~
142
253
 : This function does the same as the insert-nodes-last function except
143
254
 : it immediately applies the resulting pending updates and returns the
153
264
 :
154
265
 : @see dml:insert-nodes-last
155
266
 :
 
267
 : @deprecated please use the cdml:apply-insert-last#2 function
 
268
 :
156
269
 :)
157
270
declare %an:sequential function dml:apply-insert-nodes-last(
158
271
  $name as xs:QName,
159
272
  $content as node()*) as node()* external;
160
273
 
 
274
 
 
275
(:~
 
276
 : This function does the same as the insert-last function except it immediately
 
277
 : applies the resulting pending updates and returns the items that have been 
 
278
 : inserted.
 
279
 :
 
280
 : @param $name The name of the collection to which the items should be added.
 
281
 : @param $content The sequences of items whose copies should be added to the collection.
 
282
 :
 
283
 : @return The result of the function is the sequence of items that have been
 
284
 :         inserted into the collection.
 
285
 :
 
286
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
 
287
 :
 
288
 : @see dml:insert-last
 
289
 :
 
290
 :)
 
291
declare %an:sequential function dml:apply-insert-last(
 
292
  $name as xs:QName,
 
293
  $content as item()*) as item()* external;
 
294
 
 
295
 
161
296
(:~
162
297
 : This function does the same as the insert-nodes-before function except
163
298
 : it immediately applies the resulting pending updates and returns the
175
310
 :
176
311
 : @see dml:insert-nodes-before
177
312
 :
 
313
 : @deprecated please use the cdml:apply-insert-before#3 function
 
314
 :
178
315
 :)
179
 
declare %an:sequential function dml:apply-insert-nodes-before(
 
316
declare %an:sequential function 
 
317
dml:apply-insert-nodes-before(
180
318
  $name as xs:QName,
181
319
  $target as node(),
182
320
  $content as node()*) as node()* external;
183
321
 
 
322
 
 
323
(:~
 
324
 : This function does the same as the insert-before function except it immediately
 
325
 : applies the resulting pending updates and returns the items that have been 
 
326
 : inserted.
 
327
 :
 
328
 : @param $name The name of the collection to which the items should be added.
 
329
 : @param $target The item in the collection before which the $content
 
330
 :        sequence should be inserted.
 
331
 : @param $content The sequences of items whose copies should be added to the collection.
 
332
 :
 
333
 : @return The result of the function is the sequence of items that have been
 
334
 :         inserted into the collection.
 
335
 :
 
336
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
 
337
 :
 
338
 : @see dml:insert-before
 
339
 :
 
340
 :)
 
341
declare %an:sequential function 
 
342
dml:apply-insert-before(
 
343
  $name as xs:QName,
 
344
  $target as item(),
 
345
  $content as item()*) as item()* external;
 
346
 
 
347
 
184
348
(:~
185
349
 : This function does the same as the insert-nodes-after function except
186
350
 : it immediately applies the resulting pending updates and returns the
198
362
 :
199
363
 : @see dml:insert-nodes-after
200
364
 :
 
365
 : @deprecated please use the cdml:apply-insert-after#3 function
 
366
 :
201
367
 :)
202
 
declare %an:sequential function dml:apply-insert-nodes-after(
 
368
declare %an:sequential function 
 
369
dml:apply-insert-nodes-after(
203
370
  $name as xs:QName,
204
371
  $pos as node(),
205
372
  $content as node()*) as node()* external;
206
373
 
 
374
 
 
375
(:~
 
376
 : This function does the same as the insert-after function except it immediately
 
377
 : applies the resulting pending updates and returns the items that have been 
 
378
 : inserted.
 
379
 :
 
380
 : @param $name The name of the collection to which the items should be added.
 
381
 : @param $target The item in the collection after which the $content
 
382
 :        sequence should be inserted.
 
383
 : @param $content The sequences of items whose copies should be added to the collection.
 
384
 :
 
385
 : @return The result of the function is the sequence of items that have been
 
386
 :         inserted into the collection.
 
387
 :
 
388
 : @error zerr:ZDDY0003 if the collection identified by $name is not available.
 
389
 :
 
390
 : @see dml:insert-after
 
391
 :
 
392
 :)
 
393
declare %an:sequential function 
 
394
dml:apply-insert-after(
 
395
  $name as xs:QName,
 
396
  $pos as item(),
 
397
  $content as item()*) as item()* external;
 
398
 
 
399
 
207
400
(:~
208
401
 : The delete-nodes function is an updating function that deletes zero of more
209
402
 : nodes from a collection. 
213
406
 : @return The result of this function is an empty XDM instance and a pending update
214
407
 :         list which, once applied, deletes the nodes from their collections.
215
408
 :
216
 
 : @error zerr:ZDDY0011 if any nodes in the $target sequence is not a member of a collection
217
 
 :        or not all nodes of the $target sequence belong to the same collection.
218
 
 :
219
 
 :)
220
 
declare updating function dml:delete-nodes($target as node()*) external;
 
409
 : @error zerr:ZDDY0011 if any nodes in the $target sequence is not a member of
 
410
 :        a collection or not all nodes of the $target sequence belong to the same
 
411
 :        collection.
 
412
 :
 
413
 : @deprecated please use the cdml:delete#1 function
 
414
 :
 
415
 :)
 
416
declare updating function 
 
417
dml:delete-nodes($target as node()*) external;
 
418
 
 
419
 
 
420
(:~
 
421
 : The delete function is an updating function that deletes zero of more items
 
422
 : (nodes and/or json items) from a collection. 
 
423
 :
 
424
 : @param $target the items in the collection that should be deleted.
 
425
 :
 
426
 : @return The result of this function is an empty XDM instance and a pending update
 
427
 :         list which, once applied, deletes the items from their collections.
 
428
 :
 
429
 : @error zerr:ZDDY0011 if any item in the $target sequence is not a member of
 
430
 :        a collection or not all items of the $target sequence belong to the
 
431
 :        same collection.
 
432
 :
 
433
 :)
 
434
declare updating function 
 
435
dml:delete($target as item()*) external;
 
436
 
221
437
 
222
438
(:~
223
439
 : The delete-node-first function is an updating function that deletes the
230
446
 :
231
447
 : @error zerr:ZDDY0011 if the collection doesn't contain any node.
232
448
 :
233
 
 :)
234
 
declare updating function dml:delete-node-first($name as xs:QName) external;
 
449
 : @deprecated please use the cdml:delete-first#1 function
 
450
 :
 
451
 :)
 
452
declare updating function 
 
453
dml:delete-node-first($name as xs:QName) external;
 
454
 
 
455
 
 
456
(:~
 
457
 : The delete-first function is an updating function that deletes the first item
 
458
 : from a collection.
 
459
 :
 
460
 : @param $name The name of the collection from which the first item should be deleted.
 
461
 :
 
462
 : @return The result of this function is an empty XDM instance and a pending update
 
463
 :         list which, once applied, deletes the first item from the collection.
 
464
 :
 
465
 : @error zerr:ZDDY0011 if the collection doesn't contain any item.
 
466
 :
 
467
 :)
 
468
declare updating function 
 
469
dml:delete-first($name as xs:QName) external;
 
470
 
235
471
 
236
472
(:~
237
473
 : The delete-nodes-first function is an updating function that deletes the
246
482
 :
247
483
 : @error zerr:ZDDY0011 if the collection doesn't contain the given number of nodes.
248
484
 :
249
 
 :)
250
 
declare updating function dml:delete-nodes-first(
251
 
  $name as xs:QName,
252
 
  $number as xs:integer) external;
 
485
 : @deprecated please use the cdml:delete-first#2 function
 
486
 :
 
487
 :)
 
488
declare updating function 
 
489
dml:delete-nodes-first($name as xs:QName, $number as xs:integer) external;
 
490
 
 
491
 
 
492
(:~
 
493
 : The delete-first function is an updating function that deletes the first N
 
494
 : items from a collection.
 
495
 :
 
496
 : @param $name The name of the collection from which the first N items should be deleted.
 
497
 : @param $number The number N of items that should be removed from the beginning of
 
498
 :        the collection.
 
499
 :
 
500
 : @return The result of this function is an empty XDM instance and a pending update
 
501
 :         list which, once applied, deletes the items from the collection.
 
502
 :
 
503
 : @error zerr:ZDDY0011 if the collection doesn't contain the given number of items.
 
504
 :
 
505
 :)
 
506
declare updating function 
 
507
dml:delete-first($name as xs:QName, $number as xs:integer) external;
 
508
 
253
509
 
254
510
(:~
255
511
 : The delete-node-last function is an updating function that deletes the
256
512
 : last node from a collection.
257
513
 :
258
 
 : @param $name The name of the collection from which the first node should be deleted.
 
514
 : @param $name The name of the collection from which the last node should be deleted.
259
515
 :
260
516
 : @return The result of this function is an empty XDM instance and a pending update
261
517
 :         list which, once applied, deletes the last node from the collection.
264
520
 :        for the expanded QName $name.
265
521
 : @error zerr:ZDDY0011 if the collection doesn't contain any node.
266
522
 :
267
 
 :)
268
 
declare updating function dml:delete-node-last($name as xs:QName) external;
 
523
 : @deprecated please use the cdml:delete-last#1 function
 
524
 :
 
525
 :)
 
526
declare updating function 
 
527
dml:delete-node-last($name as xs:QName) external;
 
528
 
 
529
 
 
530
(:~
 
531
 : The delete-last function is an updating function that deletes the last item
 
532
 : from a collection.
 
533
 :
 
534
 : @param $name The name of the collection from which the last item should be deleted.
 
535
 :
 
536
 : @return The result of this function is an empty XDM instance and a pending update
 
537
 :         list which, once applied, deletes the last item from the collection.
 
538
 :
 
539
 : @error zerr:ZDDY0003 If available collections does not provide a mapping
 
540
 :        for the expanded QName $name.
 
541
 : @error zerr:ZDDY0011 if the collection doesn't contain any item.
 
542
 :
 
543
 :)
 
544
declare updating function 
 
545
dml:delete-last($name as xs:QName) external;
269
546
 
270
547
 
271
548
(:~
282
559
 :        for the expanded QName $name.
283
560
 : @error zerr:ZDDY0011 if the collection doesn't contain the given number of nodes.
284
561
 :
285
 
 :)
286
 
declare updating function dml:delete-nodes-last(
287
 
  $name as xs:QName,
288
 
  $number as xs:integer) external;
 
562
 : @deprecated please use the cdml:delete-last#2 function
 
563
 :
 
564
 :)
 
565
declare updating function 
 
566
dml:delete-nodes-last($name as xs:QName, $number as xs:integer) external;
 
567
 
 
568
 
 
569
(:~
 
570
 : The delete-last function is an updating function that deletes the last N 
 
571
 : items from an ordered collection.
 
572
 :
 
573
 : @param $name The name of the collection from which the lsat N items should be deleted.
 
574
 : @param $number The number N of items to delete.
 
575
 :
 
576
 : @return The result of this function is an empty XDM instance and a pending update
 
577
 :         list which, once applied, deletes the last N items.
 
578
 :
 
579
 : @error zerr:ZDDY0003 If available collections does not provide a mapping
 
580
 :        for the expanded QName $name.
 
581
 : @error zerr:ZDDY0011 if the collection doesn't contain the given number of items.
 
582
 :
 
583
 :)
 
584
declare updating function 
 
585
dml:delete-last($name as xs:QName, $number as xs:integer) external;
 
586
 
289
587
 
290
588
(:~
291
589
 : The truncate function is an updating function that deletes the
300
598
 :)
301
599
declare updating function dml:truncate($name as xs:QName) external;
302
600
 
303
 
(:~
304
 
 : The index-of function return the index of the given node in the collection.
305
 
 :
306
 
 : @param $node The node to retrieve the index from.
307
 
 :
308
 
 : @return Returns the position as xs:integer of the given node in the collection.
309
 
 :
310
 
 : @error zerr:ZDDY0011 if node is not contained in any collection.
311
 
 :
312
 
 :)
313
 
declare function dml:index-of($node as node()) as xs:integer external;
314
 
 
315
 
(:~
316
 
 : The collection function returns the sequence of nodes of the collection
317
 
 : identified by the given name.
318
 
 :
319
 
 : @param $name The name of the collection.
320
 
 :
321
 
 : @return The sequence contained in the given collection.
322
 
 :
323
 
 : @error zerr:ZDDY0003 If available collections does not provide a mapping
324
 
 :        for the expanded QName $name.
325
 
 :
326
 
 :)
327
 
declare function dml:collection($name as xs:QName) as node()* external;
328
 
 
329
 
(:~
330
 
 : This function returns the name of the collection the given node belongs
331
 
 : to.
332
 
 :
333
 
 : @param $node The node for which to get the name of the collection
 
601
 
 
602
(:~
 
603
 : The collection function returns the sequence of nodes and/or json items
 
604
 : that belong to the collection identified by the given name.
 
605
 :
 
606
 : @param $name The name of the collection.
 
607
 :
 
608
 : @return The sequence contained in the given collection.
 
609
 :
 
610
 : @error zerr:ZDDY0003 If available collections does not provide a mapping
 
611
 :        for the expanded QName $name.
 
612
 :
 
613
 :)
 
614
declare function dml:collection($name as xs:QName) as item()* external;
 
615
 
 
616
 
 
617
(:~
 
618
 : The collection function returns the sequence of nodes and/or json items
 
619
 : that belong to the collection identified by the given name.
 
620
 :
 
621
 : @param $name The name of the collection.
 
622
 : @param $skip The number of collection items to skip.
 
623
 :
 
624
 : @return The sequence contained in the given collection.
 
625
 :
 
626
 : @error zerr:ZDDY0003 If available collections does not provide a mapping
 
627
 :        for the expanded QName $name.
 
628
 :
 
629
 :)
 
630
declare function
 
631
dml:collection($name as xs:QName, $skip as xs:integer) as item()* external;
 
632
 
 
633
 
 
634
(:~
 
635
 : The collection function returns the sequence of nodes and/or json items
 
636
 : that belong to the collection identified by the given name.
 
637
 : The parameters $start and $skip can be used to skip over some items at
 
638
 : the beginning of the collection. If both are given, both are applied:
 
639
 : first $start to skip to the referenced item and then $skip to skip an
 
640
 : additional number of items.
 
641
 :
 
642
 : @param $name The name of the collection.
 
643
 : @param $start A reference to the first item to return. All items before
 
644
                 are skipped.
 
645
 : @param $skip The number of collection items to skip.
 
646
 :
 
647
 : @return The sequence contained in the given collection.
 
648
 :
 
649
 : @error zerr:ZAPI0028 If the given URI is not a valid node
 
650
 :        position computed by the <tt>np:node-position</tt> function. 
 
651
 : @error zerr:ZDDY0003 If available collections does not provide a mapping
 
652
 :        for the expanded QName $name.
 
653
 : @error zerr:ZSTR0066 If the passed reference $start does not reference
 
654
 :        a node from the collection identified by $name.
 
655
 :
 
656
 :)
 
657
declare function
 
658
dml:collection($name as xs:QName, 
 
659
               $start as xs:anyURI,
 
660
               $skip as xs:integer) as item()* external;
 
661
 
 
662
 
 
663
(:~
 
664
 : The collection-name function returns the name of the collection the given
 
665
 : item (node or json item) belongs to.
 
666
 :
 
667
 : @param $item The item for which to get the name of the collection
334
668
 : @return The result of this function is a QName which identifies the collection
335
 
 :         to which the given node belongs to.
336
 
 :
337
 
 : @error zerr:ZDDY0011 if the given node does not belong to a collection.
338
 
 :
339
 
 :)
340
 
declare function dml:collection-name($node as node()) as xs:QName external;
 
669
 :         to which the given item belongs to.
 
670
 :
 
671
 : @error zerr:ZDDY0011 if the given item does not belong to a collection.
 
672
 :
 
673
 :)
 
674
declare function dml:collection-name($item as item()) as xs:QName external;
 
675
 
 
676
 
 
677
(:~
 
678
 : The index-of function returns the position of the given item (node or 
 
679
 : json item) within its containing the collection.
 
680
 :
 
681
 : @param $item The item to retrieve the index from.
 
682
 :
 
683
 : @return Returns the position as xs:integer of the given item in the collection.
 
684
 :
 
685
 : @error zerr:ZDDY0011 if the item is not contained in any collection.
 
686
 :
 
687
 :)
 
688
declare function dml:index-of($item as item()) as xs:integer external;