Bug #69168 [Ver->Csd]: DomNode::getNodePath() returns invalid path

From: Date: Thu, 19 Jan 2023 13:08:07 +0000
Subject: Bug #69168 [Ver->Csd]: DomNode::getNodePath() returns invalid path
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243501@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69168&edit=1

 ID:                 69168
 Updated by:         cmb@php.net
 Reported by:        juha dot ikavalko at agentit dot fi
 Summary:            DomNode::getNodePath() returns invalid path
-Status:             Verified
+Status:             Closed
 Type:               Bug
 Package:            XSLT related
 Operating System:   Linux, Debian
 PHP Version:        7.4
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

The bug has been fixed now:
<https://github.com/php/php-src/commit/1925855c0fd14e245fe185d1cfb44bf3c29b4e14>.


Previous Comments:
------------------------------------------------------------------------
[2021-09-20 12:46:12] cmb@php.net

I can confirm the erroneous behavior with PHP-7.4 and libxml2
2.9.10.

------------------------------------------------------------------------
[2015-03-03 10:09:38] juha dot ikavalko at agentit dot fi

Description:
------------
DomNode::getNodePath() returns invalid output when node is passed to php function from XSLT.

php 5.6.4  - doesn't work
php 5.5.19 - doesn't work
php 5.4.35 - doesn't work
php 5.4.10 - OK
php 5.4.4  - OK
php 5.3.3  - OK
php 5.2    - OK

Test script:
---------------
$xml = <<<EOB
<allusers><user><uid>bob</uid></user><user><uid>joe</uid></user></allusers>
EOB;
$xsl = <<<EOB
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl">
 <xsl:template match="allusers">
    <xsl:for-each select="user">
      <xsl:value-of select="php:function('getPath',uid)"/><br />
    </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>
EOB;

function getPath($input){
  return $input[0]->getNodePath() . ' = ' . $input[0]->nodeValue;
}

$proc = new XSLTProcessor();
$proc->registerPHPFunctions();
@$proc->importStyleSheet(DOMDocument::loadXML($xsl));
echo @$proc->transformToXML(DOMDocument::loadXML($xml));

Expected result:
----------------
/allusers/user[1]/uid = bob
/allusers/user[2]/uid = joe

Actual result:
--------------
/uid = bob
/uid = joe


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69168&edit=1


Thread (3 messages)

« previous php.bugs (#243501) next »