|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Hang using XmlModify with some documents
by CristiAn Fuenzalida
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message Hi!,
I want to modify the content of a document, but the application hangs depending the content of the document i set. For this content the modify() works great: <?xml version='1.0' encoding='UTF-8' ?> <root> <nombre>valor</nombre> <nombre2 att='attval'>valor2</nombre2> </root> But for this one, the application hangs <?xml version='1.0' encoding='UTF-8' ?> <root> <nombre>valor<Test>Test2</Test><Test>Test2</Test></nombre> <nombre2 att="attval">valor2</nombre2> </root> The code i'm using to modify the content is the following: $xquery = "/root/nombre"; my $env = new DbEnv(0); $env->set_cachesize(0, 81024, 1); $env->open('/home/user/mydbxml/', Db::DB_INIT_MPOOL|Db::DB_CREATE|Db::DB_INIT_LOCK|Db::DB_INIT_LOG|Db::DB_INIT_TXN); my $theMgr = new XmlManager($env); my $container = $theMgr->openContainer('cont.dbxml', DbXml::DBXML_TRANSACTIONAL); my $queryContext = $theMgr->createQueryContext(); my $updateContext = $theMgr->createUpdateContext(); my $modify = $theMgr->createModify(); eval { my $document = $container->getDocument($docname); my $value = new XmlValue($document); my $queryExpression = $theMgr->prepare($xquery, $queryContext); $modify->addAppendStep($queryExpression, XmlModify::Element, 'Test', 'Test2'); $modify->execute($value, $queryContext, $updateContext); # THE CODE HANGS HERE }; if (my $e = catch std::exception) { print $e->what(); } I think isn't a problem caused by the use of transaction, because it works with the first XML i posted. ¿ Any ideas ? Thanks in advanced, CristiAn. |
|
|
Re: Hang using XmlModify with some documents
by George Feinberg-3
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message CristiAn,
> Hi!, > > I want to modify the content of a document, but the application > hangs depending the content of the document i set. > > For this content the modify() works great: > <?xml version='1.0' encoding='UTF-8' ?> > <root> > <nombre>valor</nombre> > <nombre2 att='attval'>valor2</nombre2> > </root> > > But for this one, the application hangs > <?xml version='1.0' encoding='UTF-8' ?> > <root> > <nombre>valor<Test>Test2</Test><Test>Test2</Test></nombre> > <nombre2 att="attval">valor2</nombre2> > </root> > > The code i'm using to modify the content is the following: > > $xquery = "/root/nombre"; > my $env = new DbEnv(0); > $env->set_cachesize(0, 81024, 1); > $env->open('/home/user/mydbxml/', > Db::DB_INIT_MPOOL|Db::DB_CREATE|Db::DB_INIT_LOCK| > Db::DB_INIT_LOG|Db::DB_INIT_TXN); > my $theMgr = new XmlManager($env); > my $container = $theMgr->openContainer('cont.dbxml', > DbXml::DBXML_TRANSACTIONAL); > my $queryContext = $theMgr->createQueryContext(); > my $updateContext = $theMgr->createUpdateContext(); > my $modify = $theMgr->createModify(); > > eval { > my $document = $container->getDocument($docname); > my $value = new XmlValue($document); > my $queryExpression = $theMgr->prepare($xquery, > $queryContext); > $modify->addAppendStep($queryExpression, > XmlModify::Element, 'Test', 'Test2'); > $modify->execute($value, $queryContext, $updateContext); > # THE CODE HANGS HERE > }; > > if (my $e = catch std::exception) { > print $e->what(); > } > > I think isn't a problem caused by the use of transaction, because > it works with the first XML i posted. > ¿ Any ideas ? Most hangs are, in fact, due to transactions and/or locks. In this case, the probable issue is that you've acquire read locks in a non-transacted getDocument(), and those locks may conflict with locks acquired during the XmlModify::execute(), which, in a transactional container, will *automatically* create a transaction, and use it for the modification. The solution is to create and use a transaction for both the XmlContainer::getDocument() and XmlModify::execute() calls. Regards, George ------------------------------------------ To remove yourself from this list, send an email to xml-unsubscribe@... |
| Free embeddable forum powered by Nabble | Forum Help |