From:             thomas dot sattler at decon-network dot de
Operating system: Linux
PHP version:      4.3.3
PHP Bug Type:     DOM XML related
Bug description:  Problem with uri-string in function xpath_register_ns()

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 bug report at http://bugs.php.net/?id=25775&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25775&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25775&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25775&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25775&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25775&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25775&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25775&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25775&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25775&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25775&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25775&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25775&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25775&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25775&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25775&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25775&r=float

Reply via email to