Re: [Xmldb-org-xupdate] Poorly defined update instruction
Brought to you by:
reinhapa
|
From: John L. C. <jl...@po...> - 2005-04-29 18:24:22
|
On Fri, Apr 29, 2005 at 10:41:28AM +0200, Wolfgang Meier wrote: > >3) It would be useful for update to allow element, attribute, etc. as=20 > >content. That said, I'm not convinced it's worth the complexity, as you= =20 > >can simply delete the element and reinsert it with the new content. >=20 > I would like to propose a "replace" instruction for this purpose. [...] > Example: >=20 > <xupdate:replace select=3D"/example/p[2]"> > <quote>a <b>replaced</b> paragraph</quote> > </xupdate:replace> This is exactly the effect that I would like the update instruction to have. If we had such a replace operation, would there be any further need for an update? It seems that the most common use case for update is a quick textual change within a #PCDATA element field; this could easily be accomplished with a simple replace. For example, the example in the spec under the update instruction could be performed with: --- <xupdate:replace select=3D"/addresses/address[2]/town/text()[1]" xmlns:xupdate=3D"http://www.xmldb.org/xupdate">New York</xupdate:replace> --- > Concerning "update", I would still allow element, text etc. as content=20 > if the "select" xpath evaluates to one or more elements. Otherwise, the= =20 > expression just updates the value of an attribute or text node. As I mentioned above, with such a replace instruction, I no longer see the point of update[0]. I actually think that either name for the instruction - "update" or "replace" - would be fine, although keeping it as "update" would be less disruptive. Take care, John L. Clark [0] In fact, I think this would simplify the spec even further - I no longer see the need for a delete operation. You could delete the "New York" text with: --- <xupdate:replace select=3D"/addresses/address[2]/town/text()[1]" xmlns:xupdate=3D"http://www.xmldb.org/xupdate"/> --- or the whole town with: --- <xupdate:replace select=3D"/addresses/address[2]/town" xmlns:xupdate=3D"http://www.xmldb.org/xupdate"/> --- |