[Xmldb-org-xupdate] Poorly defined update instruction
Brought to you by:
reinhapa
|
From: John L. C. <jl...@po...> - 2005-04-28 06:32:54
|
I think that the xupdate:update operation should have similar semantics
to the assignment operator in most programming languages. Further, I
think that as it is currently defined[0], it falls short of that goal.
I notice that in each of the three update use cases ([1], [2], and [3]),
the update is performed on a text-only node (element, attribute, or
comment, respectively). I think the selector is not specific enough (as
defined) to cover all of the cases one might want, however.
For example, consider the XML document:
test.xml:
---
<example>
<p>
foo
<em>yes!</em>
bar
</p>
</example>
---
How would you express changing "bar" to "baz" in an XUpdate operation?
The closest one can come to that node with the update operation would
be:
---
<xupdate:update select="/example/p"
xmlns:xupdate="http://www.xmldb.org/xupdate">
<xupdate:text>foo</xupdate:text>
<xupdate:element name="em">yes!</xupdate:element>
<xupdate:text>baz</xupdate:text>
</xupdate:update>
---
Where I think one should be able to directly pinpoint any node for
update, with the semantics that the node (or node set!) is replaced with
the template content, not that the selected node's *contents* is
replaced with the template content (which, I believe, is the current
model). I would want to do it this way:
---
<xupdate:update select="/example/p/text()[2]"
xmlns:xupdate="http://www.xmldb.org/xupdate">
<xupdate:text>baz</xupdate:text>
</xupdate:update>
---
I think this type of processing is clearer and more complete.
Take care,
John L. Clark
[0] http://www.smb-tec.com/xmldb/xupdate/xupdate-wd.html#N6d2633
[1] http://www.xmldatabases.org/projects/XUpdate-UseCases/#10
[2] http://www.xmldatabases.org/projects/XUpdate-UseCases/#11
[3] http://www.xmldatabases.org/projects/XUpdate-UseCases/#12
|