Thank you very much!  That gives me a much better understanding of how it
should work.



Natalia Shilenkova wrote:
> 
> On Mon, Jun 2, 2008 at 6:54 PM, sfurrh <[EMAIL PROTECTED]> wrote:
>>
>> Nevermind, I figured it out:
>>                        Update upd=new Update(Update.AFTER,xpath,xml);
>>                        String updStr=upd.toString();
>>                        System.out.println("update="+updStr);
>>                        uservice.update(updStr);
>>
>>                        Update rmv=new
>> Update(Update.REMOVE,xpath+"["+matches+"]","");
>>                        String rmvStr=rmv.toString();
>>                        System.out.println("remove="+rmvStr);
>>                        uservice.update(rmvStr);
>>
>> Where my Update class is just a utility to generate the xupdate string
>> and
>> "xml" is the new xml node and matches (in a while loop) is the index of
>> the
>> matching node.
> 
> Are you trying to replace all "config" elements in all documents in a
> collection? If replacement nodes are all the same, there is no need to
> have a loop, and the query may look similar to this:
> <xupdate:modifications version='1.0'
> xmlns:xupdate='http://www.xmldb.org/xupdate'>
> <xupdate:rename select='/site/config'>config1</xupdate:rename>
> <xupdate:insert-before select='/site/config1'>
> <xupdate:element name="config">
> <xupdate:element name="icon">images/myicon.jpg</xupdate:element>
> <xupdate:element name="title">My great new site</xupdate:element>
> </xupdate:element>
> </xupdate:insert-before>
> <xupdate:remove select='/site/config1'>
> </xupdate:remove>
> </xupdate:modifications>
> 
> Even if the replacement nodes are different, I would recommend to move
> the query for deleting nodes out of the loop - each query results in
> iterating over all documents in a collection, that would affect
> execution time of the code.
> 
> Regards,
> Natalia
> 
>>
>>
>>
>> sfurrh wrote:
>>>
>>> I am new to xindice and xmldb (though not new to xml) and I am wondering
>>> how I would go about replacing nodes.  Xupdate works fine if i want to
>>> replace the text content of a single node but how would I go about
>>> replacing an entire node that is not a collection.  For example:
>>> my collection looks like this:
>>>             <site xmlns:src="http://xml.apache.org/xindice/Query"; id="1"
>>> src:col="/db/ArtSite" src:key="1">
>>>                 <config>
>>>                     <icon />
>>>                     <title>New Site</title>
>>>                 </config>
>>>                 <owner>sean</owner>
>>>                 <studio>
>>>                     <pieces />
>>>                 </studio>
>>>                 <preferences />
>>>             </site>
>>>
>>> and i want to change the config node to look like this:
>>>                 <config>
>>>                     <icon>images/myicon.jpg</icon>
>>>                     <title>My great new site</title>
>>>                 </config>
>>>
>>> how would I do it without simply iterating through all of the nodes and
>>> xupdating them individually?
>>>
>>> thanks for any info.
>>>
>>> Sean
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Xindice---Replace-Node-tp17608708p17612662.html
>> Sent from the Xindice - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Xindice---Replace-Node-tp17608708p17624496.html
Sent from the Xindice - Dev mailing list archive at Nabble.com.

Reply via email to