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: B_INIT_M
POOL|Db: B_CREATE
|Db: B_INIT_L
OCK|
> Db: B_INIT_L
OG|Db: B_INIT_T
XN);
> my $theMgr = new XmlManager($env);
> my $container =
$theMgr->openContainer('cont.dbxml',
> DbXml: BXML_TRA
NSACTIONAL);
> 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 sleepycat.com
|