Re: [Xmldb-org-xupdate] Poorly defined update instruction
Brought to you by:
reinhapa
|
From: Ronald B. <rpb...@rp...> - 2005-04-29 06:23:34
|
1) The update expression you give is not legal -- the content of the update element is #PCDATA, not element, attribute, etc. 2) Why can't you say: <xupdate:update select="/example/p/text()[2]" xmlns:xupdate="http://www.xmldb.org/xupdate">baz</xupdate:update> It's not clear if this would work with comments and PIs. 3) It would be useful for update to allow element, attribute, etc. as content. That said, I'm not convinced it's worth the complexity, as you can simply delete the element and reinsert it with the new content. 4) I agree this should be clarified. -- Ron John L. Clark wrote: > 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 |