Project

Profile

Help

Bug #6526

open

PHP API xdmNode->axisNodes(3) returns the XdmNode itself instead of its children

Added by Martin Honnen about 2 months ago. Updated about 2 months ago.

Status:
New
Priority:
Normal
Category:
PHP API
Start date:
2024-09-10
Due date:
% Done:

0%

Estimated time:
Applies to branch:
12
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
12.5
Fixed in version:
SaxonC Languages:
SaxonC Platforms:
All
SaxonC Architecture:

Description

Trying to use axisNodes(3) with PHP to find the child nodes of an XdmNode, I get some strange results, I don't get an XdmValue containing a sequence of nodes but I get an XdmNode which seems to be the same as the method is called on.

Sample code is e.g.

<?php
$xml = <<<XML
<root att1="value 1" att2="value 2">
  <foo>bar</foo>
</root>
<!-- comment 1 -->
XML;

$saxonProc = new Saxon\SaxonProcessor();

$xdmNode = $saxonProc->parseXmlFromString($xml);

echo $xdmNode->getChildCount() . "\n";

$childrenAxis = $xdmNode->axisNodes(3);

var_dump($childrenAxis);

echo get_class($childrenAxis) . "\n";

echo $childrenAxis . "\n";


echo $childrenAxis->getNodeKind() . "\n";

$xdmNode =  $xdmNode->getChildNode(0);

echo $xdmNode->getChildCount() . "\n";

$childrenAxis = $xdmNode->axisNodes(3);

var_dump($childrenAxis);

echo get_class($childrenAxis) . "\n";

echo $childrenAxis . "\n";


echo $childrenAxis->getNodeKind() . "\n";

unset($childrenAxis);

unset($xdmNode);

unset($saxon_proc);

?>

and output for me (with SaxonC HE 12.5 under Ubuntu 24 WSL with PHP 8.3) is

2
object(Saxon\XdmNode)#3 (0) {
}
Saxon\XdmNode
<root att1="value 1" att2="value 2">
   <foo>bar</foo>
</root>

<!-- comment 1 -->
0
3
object(Saxon\XdmNode)#2 (0) {
}
Saxon\XdmNode

<foo>bar</foo>
0

Please register to edit this issue

Also available in: Atom PDF