cvs: pear /XML_XPath XPath.php
| From: | Daniel Allen | Date: | Wed, 05 Jun 2002 07:48:45 +0000 |
| Subject: | cvs: pear /XML_XPath XPath.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4416@lists.php.net to get a copy of this message | ||
dallen Wed Jun 5 03:48:45 2002 EDT
Modified files:
/pear/XML_XPath XPath.php
Log:
temporary addition of some libxml2 error capturing...the domxml module is currently
undergoing development to capture these error logs into an array, but for now I use
output buffering and then run the domxml_open_* without an @ so that errors will go
to stdout, which are then captured and passed to the PEAR::raiseError method
Index: pear/XML_XPath/XPath.php
diff -u pear/XML_XPath/XPath.php:1.8 pear/XML_XPath/XPath.php:1.9
--- pear/XML_XPath/XPath.php:1.8 Fri May 24 01:05:16 2002
+++ pear/XML_XPath/XPath.php Wed Jun 5 03:48:45 2002
@@ -17,7 +17,7 @@
// | Authors: Dan Allen <dan@mojavelinux.com> |
// +----------------------------------------------------------------------+
-// $Id: XPath.php,v 1.8 2002/05/24 05:05:16 dallen Exp $
+// $Id: XPath.php,v 1.9 2002/06/05 07:48:45 dallen Exp $
// }}}
// {{{ description
@@ -122,22 +122,27 @@
if ($this->loaded) {
return PEAR::raiseError(null, XML_XPATH_ALREADY_EXISTS, null, E_USER_WARNING,
$this->xml->root(), 'XML_XPath_Error', true);
}
+ // we need to capture errors, since there is not interface for this
+ ob_start();
// in this case, we already have an xmldom object
if ($in_type == 'object' && get_class($in_xml) ==
'DomDocument') {
$this->xml = $in_xml;
}
// we can read the file, so use xmldocfile to make a xmldom object
elseif ($in_type == 'file' && @file_exists($in_xml)) {
- $this->xml = @domxml_open_file($in_xml);
+ $this->xml = domxml_open_file($in_xml);
}
// this is a string, so attempt to make an xmldom object from string
elseif($in_type == 'string' && is_string($in_xml)) {
- $this->xml = @domxml_open_mem($in_xml);
+ $this->xml = domxml_open_mem($in_xml);
}
// not a valid xml instance, so throw error
else {
+ ob_end_clean();
return PEAR::raiseError(null, XML_XPATH_INVALID_DOCUMENT, null, E_USER_ERROR, "The
xml data '$in_xml' could not be parsed to xml dom", 'XML_XPath_Error',
true);
}
+ $loadError = ob_get_contents();
+ ob_end_clean();
// make sure a domxml object was created, and if so initialized the state
if (get_class($this->xml) == 'DomDocument') {
$this->loaded = true;
@@ -147,7 +152,7 @@
}
// we could not make a domxml object, so throw an error
else {
- return PEAR::raiseError(null, XML_XPATH_NO_DOM, null, E_USER_ERROR, "A DomDocument
could not be instantiated from '$in_xml'", 'XML_XPath_Error', true);
+ return PEAR::raiseError(null, XML_XPATH_NO_DOM, null, E_USER_ERROR,
"<b>libxml2 Message:</b> $loadError <b>Document:</b> $in_xml",
'XML_XPath_Error', true);
}
}