Thread: Php.XPath 3.2 released!!
Brought to you by:
bs_php,
nigelswinson
From: Nigel S. <nig...@us...> - 2002-07-21 18:41:32
|
Release notes: http://sourceforge.net/project/shownotes.php?group_id=36731&release_id=10078 9 Project home page: http://sourceforge.net/projects/phpxpath At last it is here!! Loads of bug fixes, many thanks to all who submitted reports. I've tagged this one as "stable" because it's been a while since there were any bug reports, but if you spot any, then let us know and we'll do another release. The biggest difference besides minor bug fixes is an internal restructure of the XPath processing engine. This has made it go a little slower, which we can do something about in the future, but it means that the expression parsing matches the expression grammer more closely and allows us to more accurately implement the XPath spec :o) Nigel |
From: Peter R. <php...@pe...> - 2002-07-22 11:10:18
|
On Saturday 20 Jul 2002 21:15, Nigel Swinson wrote: > many thanks to all who > submitted reports. many thanks for all your work, Nigel > I've tagged this one as "stable" because it's > been a while since there were any bug reports, but if you spot any, > then let us know and we'll do another release. the sum function no longer seems to work - seems to always return 0. Given: <km>100</km> <km>200</km> evaluate("sum(//km)") should surely return 300. This was working in 3.0. |
From: Philipp L. <le...@hi...> - 2002-07-22 18:36:40
|
Sorry, forgot if I mentioned -- I installed the newest PHP on my Win 98/ PWS recently, and had to change a line in the XPath-class because it didn't work anymore (I changed the single "self" reference somewhere). |
From: Nigel S. <nig...@us...> - 2002-07-22 19:31:35
|
> Sorry, forgot if I mentioned -- I installed the newest PHP on my Win 98/ > PWS recently, and had to change a line in the XPath-class because it > didn't work anymore (I changed the single "self" reference somewhere). This change went in recently (Before 3.2) ---------------------------- Revision : 1.107 Date : 2002/7/20 11:32:45 Author : 'bs_php' State : 'Exp' Lines : +3 -2 Description : PHP V4.1.x handles predefined globles differently. Had to catch that : $self = isSet($_SERVER) ? $_SERVER['PHP_SELF'] : $PHP_SELF; Is this enough for you? If not feel free to send us your change and we'll see if we can put it in the main branch... :o) Nigel =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |
From: Philipp L. <le...@hi...> - 2002-07-22 19:39:08
|
From: "Nigel Swinson" <nig...@us...> >... > This change went in recently (Before 3.2) >... > $self = isSet($_SERVER) ? $_SERVER['PHP_SELF'] : $PHP_SELF; > > Is this enough for you? If not feel free to send us your change and we'll > see if we can put it in the main branch... > Ah, that's already solved then! Thanks! |
From: Nigel S. <nig...@us...> - 2002-07-22 19:53:29
|
> > I've tagged this one as "stable" because it's > > been a while since there were any bug reports, but if you spot any, > > then let us know and we'll do another release. > > the sum function no longer seems to work - seems to always return 0. > Given: > > <km>100</km> > <km>200</km> > > evaluate("sum(//km)") > should surely return 300. > > This was working in 3.0. And the prize for finding the first 3.2 bugs goes to.... Peter :o) My humblest apologies, I never use the sum() function, and there was no entry in the test harness, so I only gave it a cursory glance during the coding for 3.2. I thought sum() took a single integer argument, when in fact it is meant to take a node set. :o( This has been fixed now, and a test added to the test harness so that future releases will never suffer from this bug :o) The changes are fairly slight, just change the function to this: function _handleFunction_sum($arguments, $context) { $arguments = trim($arguments); // Trim the arguments. // Evaluate the arguments as an XPath query. $result = $this->_evaluateExpr($arguments, $context); $sum = 0; // Create a variable to save the sum. // The sum function expects a node set as an argument. if (is_array($result)) { // Run through all results. $size = sizeOf($result); for ($i=0; $i<$size; $i++) { $value = $this->_handleFunction_number($result[$i], $context); $sum += doubleval($value); // Add it to the sum. } } return $sum; // Return the sum. } Let me know if this doesn't fix the problem properly... Nigel |
From: Peter R. <php...@pe...> - 2002-07-23 09:11:57
|
On Monday 22 Jul 2002 20:50, Nigel Swinson wrote: > > Let me know if this doesn't fix the problem properly... yup, problem seems to be fixed, thanks |
From: Tim U. <ti...@di...> - 2002-07-22 15:50:06
|
Hello all. I was using a very old version of phpxpath and have been reluctant to upgrade because it has been working so well for me. SInce I lurk here I knew the later versions were faster so I finally downloaded the latest version and decided to test it. It turns out that phpxpath is now a whole new animal and the API has changed quite a bit. Here is a snippet of how I was using this class. $xml = new XPath(); $xml->load_string ($results_xml); $a = $xml->get_attributes($xml->root); $resultcount = $a['COUNT']; if ($resultcount): // we know we have results so let's deal with them. $results = $xml->evaluate("/RESULTS/RESULT"); foreach ($results as $result): // everything we need is in here. $atrributes = $xml->get_attributes($result); $cases = $xml->evaluate($result . '/CASES/CASE'); foreach ($cases as $case): $case = $xml->get_attributes($case); foreach ($case as $key => $value): Do something here with the case attributes. endforeach; endforeach; endforeach; else: $error .= "No results found"; endif; To me this was a very neat way of dealing with XML files. Has this all now gone away? What is the eqavalent code in the new API. :wq Tim Uckun US Investigations Services/Due Diligence http://www.diligence.com/ |
From: Nigel S. <nig...@us...> - 2002-07-22 19:28:20
|
> I was using a very old version of phpxpath and have been reluctant to > upgrade because it has been working so well for me. SInce I lurk here I > knew the later versions were faster so I finally downloaded the latest > version and decided to test it. It turns out that phpxpath is now a whole > new animal and the API has changed quite a bit. Here is a snippet of how I > was using this class. We actually supported both old and new methods all the way through the 2.X branch, but expired the "old" methods as of 3.0. We changed the function names to be more like the DOM api, as we felt this would reduce the learning curve to our users. > $xml = new XPath(); > $xml->load_string ($results_xml); http://www.carrubbers.org/scripts/php/xpath/doc/#importFromString > $a = $xml->get_attributes($xml->root); http://www.carrubbers.org/scripts/php/xpath/doc/#getAttributes > $resultcount = $a['COUNT']; > > if ($resultcount): > // we know we have results so let's deal with them. > $results = $xml->evaluate("/RESULTS/RESULT"); This is still in as: http://www.carrubbers.org/scripts/php/xpath/doc/#evaluate In general it was just function name changes, but there were some differences along the way, please backup data and test well before releasing on your production site (As we should always do, and I didn't) :o) Cheers, Nigel |