php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69168 DomNode::getNodePath() returns invalid path
Submitted: 2015-03-03 10:09 UTC Modified: 2023-01-19 13:08 UTC
From: juha dot ikavalko at agentit dot fi Assigned: cmb (profile)
Status: Closed Package: XSLT related
PHP Version: 7.4 OS: Linux, Debian
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: juha dot ikavalko at agentit dot fi
New email:
PHP Version: OS:

 

 [2015-03-03 10:09 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-20 12:46 UTC] cmb@php.net
-Status: Open +Status: Verified -PHP Version: Irrelevant +PHP Version: 7.4
 [2021-09-20 12:46 UTC] cmb@php.net
I can confirm the erroneous behavior with PHP-7.4 and libxml2
2.9.10.
 [2023-01-19 13:08 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 18:01:26 2024 UTC