[Bug 4285] [UPD] Replacing optional content

http://www.w3.org/Bugs/Public/show_bug.cgi?id=4285





------- Comment #9 from jonathan.robie@datadirect.com  2007-02-26 23:24 -------
> (2) We could try a conditional with a replace-branch and an insert-branch:
> 
> if (/a/c)
> then replace /a/c with <c/>
> else insert <c/> into /a
> 
> This approach has a serious problem: the else-branch does not specify the
> position within the parent where the new node should be inserted. It cannot say
> "after /a/c" because in this branch we know that /a/c does not exist. So this
> approach is also not equivalent to the fold expression. 

Actually, I believe this is precisely equivalent to the fold proposal, which
says:

"If Parent has a child element or attribute $c with the same name and
node kind as $n, invokes upd:replaceNode($c, $n); if there is no child
element or attribute with the same name and node kind, invokes
upd:insertInto($parent, $n)."

Order is not intended to be specifiable - the reason this is easier in SQL is
precisely that (1) order does not need to be specified and (2) the system knows
that there is only one column with a given name in a table. If we try to make
fold generalize to everything you can find in an arbitrary XML document, we
lose the ability to simplify based on these two assumptions. The reason for
this proposal is to deal with a specific impedance mismatch that is irritating.

Jonathan

Received on Monday, 26 February 2007 23:24:46 UTC