我有一个带有以下标题的XSLT样式表
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="redirect"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:my-ext="ext1">我也有自定义功能:
<msxsl:script language="JavaScript" implements-prefix="my-ext">
var lineCounter = 0;
var totalPages = 0;
var currentPage = 1;
var currentObject = '';
var colSpan = 0;
function getLineCounter()
{
return lineCounter;
}
function updateLineCounter(aValue)
{
lineCounter += aValue;
return '';
}我的自定义函数在整个xsl中使用。当我使用这个XSL从命令行转换我的XML时,使用msxsl.exe,它完美地工作并生成完美的。
好的,我的问题是:我试图使用PHP在服务器上执行转换并发送结果。我以前多次使用这个过程,没有问题;但是,这是我第一次用MSXSL扩展和函数来尝试这个过程。
示例错误如下所示:
Warning: XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: xmlXPathCompOpEval: **function resetAll not found** in D:\Development\AppServ\www\RJFWEB\jqueryFileTree\PHPMain.php on line 49
Warning: XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: **Unregistered function** in D:\Development\AppServ\www\RJFWEB\jqueryFileTree\PHPMain.php on line 49我们可以看到没有找到/理解函数--尽管这是我使用msXSL.exe.在命令行运行的相同代码。
因此,最终,我试图找出是否需要在我的PHP.ini中修复/添加一些东西来理解如何使用MS扩展,还是需要更改XSL样式表?
伙计..。我希望这个问题有意义!任何帮助都很感激。谢谢。
抢夺
我的phpInfo显示器
**XSL**
XSL enabled
libxslt Version 1.1.23
libxslt compiled against libxml Version 2.6.32
EXSLT enabled
libexslt Version 0.8.13发布于 2012-10-10 12:03:18
msxsl:script是一个专有的扩展,允许您使用JScript或VBScript编写扩展函数,我认为libxslt不支持这一点。但是,使用PHP 5和libxslt,您可以用PHP编写扩展函数,请参阅http://php.net/manual/en/xsltprocessor.registerphpfunctions.php。因此,这似乎是可行的方法,如果您不能使用纯XSLT来实现您的需求,那么您需要将用J(Ava)脚本编写的函数移植到PHP,并使用http://php.net/manual/en/xsltprocessor.registerphpfunctions.php在XSLT中使用这些函数。
作为另一种选择,如果您在有MSXML可用的Windows上运行PHP,您可能希望尝试从PHP中使用它,应该可以在http://www.php.net/manual/en/class.com.php的帮助下使用它,例如,new COM("MSXML2.DomDocument.3.0")应该给您一个带有transformNode方法的MSXML文档,以便使用msxsl:script运行样式表。
https://stackoverflow.com/questions/12815665
复制相似问题