Re: [Xmldb-org-xupdate] Poorly defined update instruction
Brought to you by:
reinhapa
|
From: John L. C. <jl...@po...> - 2005-05-25 05:59:24
|
On Wed, May 11, 2005 at 04:42:43PM -0700, Ronald Bourret wrote: > John L. Clark wrote: > >I would prefer that the latter be made normative (that is, that > >update be treated precisely as node replacement, hence my original > >argument about the assignment operator semantics). >=20 > I prefer content replacement to node replacement. Node replacement would= =20 > mean that if I selected the node <date>10/11/12</date>, I would have to= =20 > include the <date> markup in my update instruction, which feels=20 > unnatural when all I want to do is change the date. The content of an element is a node[0]. If all you want to do is change the date, then you want to change the date element's content node, not the date node itself. More precisely, the node you want to change is represented by the XPath expression /date/text(), which more precisely expresses the target of the replacement (that is, the text, *not* the whole element). I think this is why it feels unnatural; if you want to change the whole element, then you should both address that element precisely and include the new element in the update content. This example is akin to my modification of the example from the specification: --- <xupdate:update select=3D"/addresses/address[2]/town/text()[1]" xmlns:xupdate=3D"http://www.xmldb.org/xupdate">New York</xupdate:update> --- Which selects the first text node within the town element and chooses to update *that*. In your example, you don't want to update the whole element, just the text child of that element (informally, that element's content), and so I think that you should be required to address the node that you want to update precisely. > This also shows why it would be useful to have an xupdate:replace=20 > element as Wolfgang suggests. This would allow me to replace the <date>= =20 > element with <birthday>, for example. To my mind, this is very distinct= =20 > from changing a value. As detailed above, I disagree. You can use the current xupdate:update to satisfy both of these use cases with an appropriate XPath expression. Take care, John L. Clark [0] http://www.w3.org/TR/xpath.html#data-model |