Thanks, but same results.

when I put the example code up there I also was thinking who would ever need
to set and then read the same information.  Unfortunately our real case
scenario runs into this.

Just for reference: We have a complex workflow, so have no idea where we are
in the workflow we are when information is passed to through it.  We have a
case, which is how we found this problem, where data is set and then in
another point in the workflow the information is accessed.  Only work around
we could come up with was to hard code an indicator which identified when we
were in this problem section so that it would ignore reading the newly set
data and use the information we had previously set.

Thanks for the help.

Rob

----- Original Message -----
From: "Joseph Tate" <[EMAIL PROTECTED]>
To: "Rob Richards" <[EMAIL PROTECTED]>; "Php-Dev List"
<[EMAIL PROTECTED]>
Sent: Wednesday, February 13, 2002 11:51 AM
Subject: RE: Bug #15530 Updated: conent of node node correct reading new DOM
value after set_content of node


> Ok, try the following code:
>
> function getContent ($n)
> {
>     if (!($children = $n->children())) return '';
>
>     $content = '';
>     foreach ($children as $c) {
>         if ($c->type == XML_TEXT_NODE) {
>             $content .= $c->content;
>         }
>     }
>
>     return $content;
> }
>
> Then use getContent($n) rather than $n->content.  This could fix your
> problem, but I'm not sure.  It still uses the ->content property (though
in
> a TEXT_NODE context).  I don't actually make changes and then read back
the
> contents in any of my code, so this is new to me.
>
> As for the time frame for the next release of php?  I don't know.
>
> Joseph
>
> > -----Original Message-----
> > From: Rob Richards [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, February 13, 2002 11:42 AM
> > To: Joseph Tate
> > Subject: Re: Bug #15530 Updated: conent of node node correct reading new
> > DOM value after set_content of node
> >
> >
> > Management's definition of a custom build is any package or port
> > that we use
> > not coming from a maintainer - go figure.  This includes grabbing CVS
> > updates.  Losing battle trying to argue this with them.
> >
> > We have built a package for RedHat 7.2, 7.1 as well as FreeBSD,  but the
> > ultimate server is out of our control and they will only use the FreeBSD
> > ports they can pull from within it.
> >
> > Basically, we are stuck with our code needing to run on the
> > FreeBSD version
> > they run which right now only is up to revision 1.90 of the domxml code.
> >
> > Do you happen to know any time frame for a next release?  This may not
be
> > much of a problem depending upon that.
> >
> > Thanks,
> >
> > Rob
> >
> > ----- Original Message -----
> > From: "Joseph Tate" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>; "Php-Dev List" <[EMAIL PROTECTED]>
> > Sent: Wednesday, February 13, 2002 11:19 AM
> > Subject: RE: Bug #15530 Updated: conent of node node correct
> > reading new DOM
> > value after set_content of node
> >
> >
> > > You kind of have to have a custom php build anyway because DOMXML
stuff
> > > isn't part of the RH php installation.  I've got rpms for RH 7.2 if
that
> > > will help.  They don't have the get_content stuff, but I could
> > add that to
> > > my custom patch (that fixes bug #14934) no problem.  Besides,
> > it'll be in
> > > the next release; it's not "custom code" in the purest definition of
the
> > > term.
> > >
> > > Joseph
> > >
> > > > -----Original Message-----
> > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > > > Sent: Wednesday, February 13, 2002 11:04 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Bug #15530 Updated: conent of node node correct
> > reading new DOM
> > > > value after set_content of node
> > > >
> > > >
> > > >  ID:               15530
> > > >  Updated by:       [EMAIL PROTECTED]
> > > >  Reported By:      [EMAIL PROTECTED]
> > > >  Status:           Open
> > > >  Bug Type:         DOM XML related
> > > >  Operating System: RedHat 7.2
> > > >  PHP Version:      4.1.1
> > > >  New Comment:
> > > >
> > > > Any other workaround for the get_content problem?  We can use a
custom
> > > > php build on our development machines, but cant on the server
> > where the
> > > > code will actually be going.
> > > >
> > > > Thanks
> > > >
> > > >
> > > > Previous Comments:
> > > >
> > ------------------------------------------------------------------------
> > > >
> > > > [2002-02-13 10:43:55] [EMAIL PROTECTED]
> > > >
> > > > The problem is that the content property is going away, so that
> > > > property is not set.  This is why it's not being updated.  It's
being
> > > > replaced by a get_content() function.  This is in CVS at this very
> > > > moment.
> > > >
> > > > As for the appending of xml contents, the comment in the code is as
> > > > follows:
> > > > // FIXME: another gotcha. If node has children, calling
> > > > // xmlNodeSetContent will remove the children -> we loose the zval's
> > > > // To prevent crash, append content if children are set
> > > >
> > > >
> > > > I think if you just used the get_content() function instead of the
> > > > ->content property that your problem would go away.  Of course
you're
> > > > going to have to pull it from CVS.
> > > >
> > > >
> > ------------------------------------------------------------------------
> > > >
> > > > [2002-02-12 16:18:23] [EMAIL PROTECTED]
> > > >
> > > > The following simplied script shows that when we update the value of
a
> > > > node, the DOM is updated as shown through the dump.  When you try to
> > > > read the content of the node however, it returns the origional
value.
> > > >
> > > >
> > > > If this is a bug, is there any known workaround to get the desired
> > > > result?
> > > >
> > > > Also, we had to use the set_content as provided in the script
because
> > > > if a node already has a value and we try to call set_content
directly
> > > > on the node rather than on the the text element (value node), it
> > > > appends the data to the node rather than overwriting the exisitng
> > > > value.
> > > >
> > > > XPath is used in here as our real XML data is quite complex so
needed
> > > > to illustrate how we were finding the correct node.
> > > >
> > > > <?
> > > > $xmltest = "<root_node><node1>ORG VALUE</node1></root_node>";
> > > > $mydoc = xmldoc($xmltest);
> > > > echo "<pre>".$mydoc->dumpmem()."</pre><br>";
> > > > $ctx=$mydoc->xpath_new_context();
> > > > $query_xo = xpath_eval($ctx,"/root_node/node1");
> > > > $oNode = $query_xo->nodeset[0];
> > > > if (is_null($oNode)) {
> > > > $root = $$mydoc->root();
> > > > $root->new_child("node1", "empty");
> > > > } else {
> > > > $tNode = $oNode->first_child();
> > > > $tNode->set_content("VALUE1");
> > > > }
> > > > echo "<pre>".$mydoc->dumpmem()."</pre><br>";
> > > > $ctx2=$mydoc->xpath_new_context();
> > > > $query_xo = xpath_eval($ctx2,"/root_node/node1");
> > > > $oNode = $query_xo->nodeset[0];
> > > > if (! is_null($oNode)) {
> > > > $tNode = $oNode->first_child();
> > > > $strValue = $tNode->content;
> > > > }
> > > > echo "<br>GET VAL".$strValue."<br>";
> > > > echo "<pre>".$mydoc->dumpmem()."</pre>";
> > > > ?>
> > > >
> > > >
> > > >
> > ------------------------------------------------------------------------
> > > >
> > > >
> > > > --
> > > > Edit this bug report at http://bugs.php.net/?id=15530&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to