List Info

Thread: Hang using XmlModify with some documents




Hang using XmlModify with some documents
user name
2006-07-05 16:38:39
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&lt;/nombre&gt;
  <nombre2 att='attval'>valor2</nombre2>
<;/root>

But for this one, the application hangs
<?xml version='1.0' encoding='UTF-8' ?>
<;root>
  ; &nbsp; &nbsp;  <nombre>valor&lt;Test>Test2</Test><Test>Test2</Test&gt;</nombre>
&nbsp; &nbsp;   ;  <nombre2 att="attval";>valor2</nombre2>
</root>

The code i'm using to modify the content is the following:

 &nbsp; $xquery = "/root/nombre&quot;;
 ; &nbsp; my $env = new DbEnv(0);
 &nbsp;  $env->set_cachesize(0, 81024, 1);
 ; &nbsp; $env->open('/home/user/mydbxml/',
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  Db:B_INIT_MPOOL|Db:B_CREATE|Db:B_INIT_LOCK|Db:B_INIT_LOG|Db:B_INIT_TXN);
 &nbsp;  my $theMgr = new XmlManager($env);
&nbsp; &nbsp; my $container = $theMgr-&gt;openContainer('cont.dbxml', DbXml:BXML_TRANSACTIONAL);
 &nbsp;  my $queryContext = $theMgr-&gt;createQueryContext();
 &nbsp;  my $updateContext = $theMgr-&gt;createUpdateContext();
 &nbsp;  my $modify = $theMgr-&gt;createModify();

&nbsp;   eval {
 &nbsp;   ; &nbsp; my $document = $container->getDocument($docname);
&nbsp; &nbsp; &nbsp; &nbsp; my $value = new XmlValue($document);
 &nbsp; &nbsp; &nbsp;  my $queryExpression = $theMgr-&gt;prepare($xquery, $queryContext);
&nbsp; &nbsp; &nbsp; &nbsp;   $modify-&gt;addAppendStep($queryExpression, XmlModify::Element, 'Test', 'Test2');
 &nbsp; &nbsp; &nbsp; &nbsp;  $modify-&gt;execute($value, $queryContext, $updateContext); ; # THE CODE HANGS HERE
&nbsp; &nbsp; };

&nbsp; &nbsp; if (my $e = catch std::exception) {
 &nbsp;   ; print $e->what();
 ; &nbsp; }

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.

Hang using XmlModify with some documents
user name
2006-07-06 13:02:13
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-unsubscribesleepycat.com

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )