Saxon/X PHP API 样式表编译失败 - 获取有用的错误通知


Saxon/X PHP API Stylesheet compilation failed - get useful error notice

我在我的PHP中使用Saxon/C API作为XSLT 2.0处理器版本1.0.0。我使用了0.3版,它完美地编译了我的样式表。不幸的是,0.3 在我需要的一个函数中有一个错误,所以我升级到 1.0.0。错误消失了,但现在它不编译我的 XSTL 并说

net.sf.saxon.s9api.SaxonApiException : Stylesheet compilation failed: 1 error reported

这绝对没有帮助。样式表包含数十个文件并且非常复杂(否则我会使用 libxml),因此如果没有适当的错误消息,我没有丝毫机会找出问题所在(或在此处发布)。那么,如何获得可以使用的错误消息?

提前感谢!

--

我的PHP代码(而不是这里提到的例子):

$saxonProc = new 'Saxon'SaxonProcessor();
$saxon = $saxonProc->newXsltProcessor();
$saxon->setSourceFromFile('source.xml');
$saxon->compileFromFile('style.xml');
$result = $saxon->transformToString();
if($result == NULL) {
    $errCount = $saxon->getExceptionCount();
    if($errCount > 0 ){
        for($i = 0; $i < $errCount; $i++) {
            $errCode = $saxon->getErrorCode(intval($i));
            $errMessage = $saxon->getErrorMessage(intval($i));
            echo 'Error: Code='.$errCode.' Message='.$errMessage;
        }
        $saxon->exceptionClear();
    }
}
echo $result;
$saxon->clearParameters();
$saxon->clearProperties();

样式表的开头:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:t="http://www.tei-c.org/ns/1.0"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   exclude-result-prefixes="t" version="2.0">
   <xsl:output method="xml" encoding="UTF-8"/>
   <xsl:include href="global-varsandparams.xsl"/>

确切的错误详细信息应出现在 apache 日志文件中。此外,累积的错误应该可以通过getErrorCode和getErrorMessage访问。我看到您在示例中对此进行了调用。如果它没有出现在这里,那么我怀疑这是一个值得提交的错误。