You cannot call the php function solution after registerPHPFunctions in XSLTProcessor. XSLT is a very convenient tool for XML conversion. in PHP, it is implemented through javastprocessor. in XSLT, many useful functions are built in. at the same time, you only need to call the XSLTProcessor instance XSLT, which is a very convenient tool for XML conversion. PHP uses XSLTProcessor to implement it. XSLT contains many useful functions. at the same time, you only need to call the registerPHPFunctions method of the XSLTProcessor instance to directly use the PHP function in XSLT, which greatly enhances the processing capability of XSLT.
However, when using PHP functions in XSLT, many people encounter the following two errors:
(1) Warning: effectprocessor: transformToXml (): xmlXPathCompiledEval: 1 objects left o
N the stack.
(2) PHP Warning: effectprocessor: transformToXml (): xmlXPathCompOpEval: function func
Tion bound to undefined prefix php in ....
The code is as follows: |
|
$ Xml = < Bob Joe EOB; $ Xsl = < Xmlns: xsl = "http://www.w3.org/1999/XSL/Transform"> Users
Select = "php: function ('ucfirst', string (uid)"/> |
EOB; $ Xmldoc = DOMDocument: loadXML ($ xml ); $ Export doc = DOMDocument: loadXML ($ xsl ); $ Proc = new effectprocessor (); $ Proc-> registerPHPFunctions (); $ Proc-> importStyleSheet ($ export Doc ); Echo $ proc-> transformToXML ($ xmldoc ); ?> |
In fact, this error occurs because we have not defined the PHP namespace.
The code is as follows: |
|
Xmlns: xsl = "http://www.w3.org/1999/XSL/Transform">
|
Add xmlns: php = "http://php.net/xsl" to solve this problem, that is
The code is as follows: |
|
Xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" Xmlns: php = "http://php.net/xsl"> |
Http://www.bkjia.com/PHPjc/632243.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632243.htmlTechArticleXSLT is a very convenient tool to convert XML, PHP is implemented through XSLTProcessor; XSLT has many built-in useful functions, at the same time, only need to call XSLTProcessor instance...