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: -
From: juha dot ikavalko at agentit dot fi Assigned:
Status: Open Package: XSLT related
PHP Version: Irrelevant OS: Linux, Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or 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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 15:01:27 2019 UTC