|
XUpdate: how to replace a node?: msg#00195text.xml.exist
Hi, I need to replace a given node in my database by a whole new node. First, is the XUpdate documentation found on http://xmldb-org.sourceforge.net/xupdate/xupdate-wd.html current enough? Well, this documentation doesn't mention any replace functionality. So I thought that I could just remove the node, and add the new node to the parent, at the same position. Problem: in order to be able to append the new node to the parent, I need to put a reference to the parent in a variable before deleting the old node: my XPath to the node is like //node[@id="2"], so I can easily find the parent before deleting the node, but it is impossible afterwards. The problem is that I cannot define variables in xupdate: <xu:variable name="n" select="document('/db/doc.xml')//node[@id='2']"/> is exactly as effective as: <xu:grunt name="n" select="document('/db/doc.xml')//node[@id='2']"/> or: <xu:foo name="n" select="document('/db/doc.xml')//node[@id='2']"/> or whatever... (by the way, is it normal for eXist not to report unknown elements?) I also tried to define the variables in the surrounding xquery, and use them from within the xupdate, but I get an error saying "select expression should evaluate to a node-set; got xs:integer". This is the syntax I used: let $node := document('/db/doc.xml')//node[@n='2'] let $parent := $node/.. let $mods := xmldb:update($root, <xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate"> <xu:append select="{$parent}" child="0"> <foo/> </xu:append> </xu:modifications> ) Well, so here I'm stuck, is there any "official way" to replace nodes? ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | XQuery part good, part bad, todays snapshot: 00195, Amotz Anner |
|---|---|
| Next by Date: | Few questions for Wolfgang and eXist folks: 00195, Sava Jurisic |
| Previous by Thread: | XQuery part good, part bad, todays snapshoti: 00195, Amotz Anner |
| Next by Thread: | Re: XUpdate: how to replace a node?: 00195, Wolfgang Meier |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |