#25775 [Opn->Fbk]: Problem with uri-string in function xpath_register_ns()
| From: | chregu@php.net | Date: | Wed, 08 Oct 2003 09:14:08 +0000 |
| Subject: | #25775 [Opn->Fbk]: Problem with uri-string in function xpath_register_ns() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-48696@lists.php.net to get a copy of this message | ||
ID: 25775
Updated by: chregu@php.net
Reported By: thomas dot sattler at decon-network dot de
-Status: Open
+Status: Feedback
Bug Type: DOM XML related
Operating System: Linux
PHP Version: 4.3.3
New Comment:
Works for me with:
PHP 4.3.4-dev (cli) on Linux
and
PHP 4.3.2-RC3-dev (cli) on OS X
chregu
Previous Comments:
------------------------------------------------------------------------
[2003-10-07 06:16:07] thomas dot sattler at decon-network dot de
Description:
------------
If you whrite a string like "http://..." or 'http://...' into the
xpath_register_ns function there will occur a problem with a
stringlength between 16 and 23 characters and also between 40 and 47
characters.
Example:
$ctx->xpath_register_ns ("pre", 'http://www.xyz.de/');
The result is the same when the registered uri differs from the uri in
the XML-file:
There is no result object if evaluate an xpath with the registered
namespace (like "/pre:foo").
If you define the uri in a variable (i.e. $uri) and write the
xpath_register_ns() function with all is fine.
Reproduce code:
---------------
<?PHP
$s = '<?xml version="1.0" ?>';
$s .= '<test:foo xmlns:test="http://www.xyz.de/abc.xyz">';
$s .= '<test:bar>abc';
$s .= '</test:bar>';
$s .= '</test:foo>';
// namespace uri as string
$doc = domxml_open_mem($s);
$ctx_p = xpath_new_context($doc);
$reg_succ_p = $ctx_p->xpath_register_ns ("test",
'http://www.xyz.de/abc.xyz');
$p = xpath_eval($ctx_p, '/test:foo/test:bar');
$uri="http://www.xyz.de/abc.xyz";
//namespace uri in $uri
$ctx_q = xpath_new_context($doc);
$reg_succ_q = $ctx_q->xpath_register_ns("test", $uri);
$q = xpath_eval($ctx_q, '/test:foo/test:bar');
echo '<PRE><br>$p: '; print_r($p);
echo '<br>$q: '; print_r($q);
echo "</PRE>";
?>
Expected result:
----------------
Both xpath_eval commands shood produce the same result:
The expected output is:
$p: XPathObject Object
(
[type] => 1
[nodeset] => Array
(
[0] => domelement Object
(
[type] => 1
[tagname] => bar
[0] => 4
[1] => 135761016
)
)
)
$q: XPathObject Object
(
[type] => 1
[nodeset] => Array
(
[0] => domelement Object
(
[type] => 1
[tagname] => bar
[0] => 4
[1] => 135761016
)
)
)
Actual result:
--------------
Only the second xpath evaluation where the registered uri is given as
variable ($uri) is successful.
$p:
$q: XPathObject Object
(
[type] => 1
[nodeset] => Array
(
[0] => domelement Object
(
[type] => 1
[tagname] => bar
[0] => 5
[1] => 136278112
)
)
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25775&edit=1