Re: [Xmldb-org-xupdate] append and insert-*: redundant?
Brought to you by:
reinhapa
|
From: Ronald B. <rpb...@rp...> - 2005-04-29 06:12:48
|
The spec does not say what happens in insert-before or insert-after when the XPath specified by the select attribute evaluates to an empty set. So perhaps append is required in this case, although this might be a hole in the spec instead. (It's actually not clear what to do with insert when the node set is empty. If it's empty because there are no children, the user might conceivably want append semantics. On the other hand, if it's empty because there were no children of the desired type, the user might want an error. Note that the spec also does not say what to do when the node set evaluates to more than one node.) Except in this case, it seems that append is a redundant shorthand for the useful case in which you simply want to add a child and don't care / don't know what other children exist. It is redundant because you can always write an XPath that evaluates to the last child node of a given parent (modulo the aforementioned no-child case). Personally, I think it's useful enough to be worth keeping. -- Ron John L. Clark wrote: > Is it true that xupdate:insert-after and xupdate:insert-before provide a > proper subset of the functionality of xupdate:append? In particular, > xupdate:append can be used to create a new child of the context node > in the case where there were no children of that context node, but in > those cases where there are children of a context node, it seems that > you could use xupdate:append or one of xupdate:insert-after and > xupdate:insert-before interchangeably. > > If this observation is correct, then why do xupdate:insert-after and > xupdate:insert-before exist? > > Take care, > > John L. Clark |