[Bug 4285] [UPD] Replacing optional content

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





------- Comment #5 from chamberl@almaden.ibm.com  2007-02-12 21:00 -------
As stated, the "fold" proposal fails to address an important issue.

Consider the example

fold <c/> into /a

If /a/c exists, the semantics are equivalent to 
replace /a/c with <c/>
and these semantics are well-defined.

If /a/c does not exist, the semantics are equivalent to
insert <c/> into /a
which causes a new c-element to be inserted into a non-deterministic position
within /a. 

But the user will probably want to control the position of the new c-element
within its parent. The user may intend the new node to be the first child of
its parent, or the last child of its parent, or just before or after some
designated sibling. These options are all supported by the insert expression
but are missing from the proposed "fold" expression.

The missing functionality could be added to the "fold" expression by allowing
the "into $parent" clause to take any of the following forms:

into $parent
as first into $parent
as last into $parent
before $sibling
after $sibling

Consider the following example:

fold <c/> after /a/b

The semantics would be as follows:

if /a/b/../c exists, semantics are equivalent to
replace /a/b/../c with <c/>

If /a/b/../c does not exist, semantics are equivalent to
insert <c/> after /a/b

It is worth noting that specifying "after", "as last", etc. can be done fairly
easily with the keyword-syntax approach (Jonathan's Version 1) but not with the
functional approach (Jonathan's Version 2).

This comment is not intended to express support or lack of support for the
"fold" proposal, but simply to call attention to an issue that needs to be
resolved to make the proposal well-specified.

Regards,
Don Chamberlin

Received on Monday, 12 February 2007 21:00:56 UTC