dbTalk Databases Forums  

addInsertAfterStep vs addInsertBeforeStep

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss addInsertAfterStep vs addInsertBeforeStep in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
rodablo@gmail.com
 
Posts: n/a

Default addInsertAfterStep vs addInsertBeforeStep - 01-27-2006 , 09:00 AM






hi:

I´m trying to modify a node too, but if I do
addRemoveStep/addInsertAfterStep, I get an "XmlModify::execute: cannot
insert after a node with no parent" (because was already remove it i
guess), the sequence addInsertBeforeStep follow by the addRemoveStep
works fine.

the question:
1. Is this behavior OK? is the right way? (insertBefore BEFORE remove
I´meant)
2. I notice that addInsertXXX parses the data but I already have an
XmlDocument, Can I pass the DOM inside to the modify in any way to
avoid the extra conversion?

Thanks in advance!

the code and the data follow:

the database is something like this:

<root_tag>
<entry number="XXX">
... node content...

the query returns:

<entry number="1234">
... node content...

an extract of the code:

XmlDocument doc = mgr.createDocument();

Multipart_XmlInputStream * stream =
new Multipart_XmlInputStream(this->io_.handle (),
initial_data, part_length);
doc.setContentAsXmlInputStream(content);

// I should avoid this
std::string d2;
/*std::string & d3 =*/ doc.getContent(d2);

/// this runs the query and validate the new data
/// and updates the results_
if (Accessor::execute (query, doc))
{
// throws an exception
}

XmlModify modify = mgr.createModify();

/// @note this select the entry tag itself
XmlQueryExpression e = mgr.prepare(this->txn_, ".", context_);

// this line works
modify.addInsertBeforeStep(e, XmlModify::Element, "", d2);
modify.addRemoveStep(e);
// this line throws an exception
// (1184) Line: 64 File: Mutator.cpp - Mutator::execute - Berkeley
exception: Error:
// XmlModify::execute: cannot insert after a node with no parent
// modify.addInsertAfterStep(e, XmlModify::Element, "", d2);

XmlUpdateContext uc = mgr.createUpdateContext();

unsigned int noOfModifications = modify.execute(this->txn_,
this->results_,
this->context_, uc);
txn_.commit();


Reply With Quote
  #2  
Old   
John Snelson
 
Posts: n/a

Default Re: addInsertAfterStep vs addInsertBeforeStep - 01-30-2006 , 05:55 AM






Hi,

rodablo (AT) gmail (DOT) com wrote:
Quote:
I´m trying to modify a node too, but if I do
addRemoveStep/addInsertAfterStep, I get an "XmlModify::execute: cannot
insert after a node with no parent" (because was already remove it i
guess), the sequence addInsertBeforeStep follow by the addRemoveStep
works fine.

the question:
1. Is this behavior OK? is the right way? (insertBefore BEFORE remove
I´meant)
Yes, that is the right way to do what you want. XmlModify steps are
executed one after the other, in the order they are specified.

Quote:
2. I notice that addInsertXXX parses the data but I already have an
XmlDocument, Can I pass the DOM inside to the modify in any way to
avoid the extra conversion?
There is currently no way to pass in an existing XmlDocument or
XmlValue as the content to be added during an XmlModify step. However,
that may be something for us to consider implementing in the future.

John



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.