Generalization of Deep Updates #1225
Labels
Discussion
A discussion on a general topic.
PRG-hard
Categorized as "hard" at the Prague f2f, 2024
PRG-optional
Categorized as "optional for 4.0" at the Prague f2f, 2024
Propose for V4.0
The WG should consider this item critical to 4.0
XPath
An issue related to XPath
Note: This is a discussion issue, as I cannot contribute something substantial so far.
Observations
Our current development to support updates in the languages may come as a surprise to developers:
I think we should…
I believe 2. is more realistic. By providing a simplified syntax, we could tackle some of the shortcomings of XQUF, such as its verbosity, and seemingly unnecessary restrictions:
XQUF: Verbosity
The Transform expression (or Copy Modify expression, as it’s called in 3.0) has a cumbersome and wordy syntax for doing very trivial things:
The 3.0 Transform With syntax is a bit simpler, it utilizes the context item:
It resulted from the BaseX
update
syntax……which comes with an ambiguity that forbids its unchanged adoption:
element update {}
could be both an element constructor and an update statement. I think that dropping the curly braces (and, optionally, using parentheses) would resolve this issue.XQUF: Restrictions
The XQUF syntax is very powerful, but it has some restrictions that require the use of FLWOR expressions when addressing multiple nodes. For example, the following statement is illegal…
…if the target is not a single node, which means that you have to write…
…or…
I’m pretty sure it would be safe to drop the restriction, which also exists for other update expressions, such as
insert nodes NODES into SINGLE-NODE
orrename node NODE as 'NAME'
(delete nodes NODES
is legal). Allowing multiple targets would greatly reduce the number of iterations required within update blocks in practice.XQuery Update light
I think the new update syntax should meet the following requirements (among others):
First, we would need to decide on a syntax that would be applicable to both maps/arrays and nodes. We could:
Syntax 2. and 3. is challenging, as the type of the input can only be evaluated at time (and for XQUF it has to be determined statically whether an expression is an updating or non-updating).
As we currently have a proposal for 1., I will stick to that syntax, but allow an optional plural form for
map
andarray
(inspired by XQUF), and use chains. Within the the update block, we could now use the short syntax also for nodes without thenode
/nodes
keywords:Semantics
I’m looking forward to everyone’s opinions.
The text was updated successfully, but these errors were encountered: