File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ bug #69168 (DomNode::getNodePath() returns invalid path)
3
+ --EXTENSIONS--
4
+ xsl
5
+ --FILE--
6
+ <?php
7
+ $ xml = <<<EOB
8
+ <allusers><user><uid>bob</uid></user><user><uid>joe</uid></user></allusers>
9
+ EOB ;
10
+ $ xsl = <<<EOB
11
+ <?xml version="1.0" encoding="UTF-8"?>
12
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
13
+ <xsl:template match="allusers">
14
+ <xsl:for-each select="user">
15
+ <xsl:value-of select="php:function('getPath',uid)"/><br />
16
+ </xsl:for-each>
17
+ </xsl:template>
18
+ </xsl:stylesheet>
19
+ EOB ;
20
+
21
+ function getPath ($ input ){
22
+ $ input [0 ]->nodeValue .= 'a ' ;
23
+ return $ input [0 ]->getNodePath () . ' = ' . $ input [0 ]->nodeValue ;
24
+ }
25
+
26
+ $ proc = new XSLTProcessor ();
27
+ $ proc ->registerPHPFunctions ();
28
+ $ xslDoc = new DOMDocument ();
29
+ $ xslDoc ->loadXML ($ xsl );
30
+ @$ proc ->importStyleSheet ($ xslDoc );
31
+ $ xmlDoc = new DOMDocument ();
32
+ $ xmlDoc ->loadXML ($ xml );
33
+ echo @$ proc ->transformToXML ($ xmlDoc );
34
+
35
+ // Tests modification of the nodes
36
+ var_dump ($ xmlDoc ->firstChild ->firstChild ->firstChild ->getNodePath ());
37
+ var_dump ($ xmlDoc ->firstChild ->firstChild ->firstChild ->nodeValue );
38
+ ?>
39
+ --EXPECT--
40
+ <? xml version="1.0 "?>
41
+ /allusers/user[1]/uid = boba<br/>/allusers/user[2]/uid = joea<br/>
42
+ string(21) "/allusers/user[1]/uid"
43
+ string(4) "boba"
You can’t perform that action at this time.
0 commit comments