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

From: Date: Mon, 20 Sep 2021 12:46:12 +0000
Subject: Bug #69168 [Opn->Ver]: DomNode::getNodePath() returns invalid path
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236709@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:             Open
+Status:             Verified
 Type:               Bug
 Package:            XSLT related
 Operating System:   Linux, Debian
-PHP Version:        Irrelevant
+PHP Version:        7.4
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[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 (#236709) next »