SaxonC v12.7/v12.8中SaxonApiException重复输出相同错误信息的问题咨询
SaxonC v12.7/v12.8中SaxonApiException重复输出相同错误信息的问题咨询
大家好,我最近在使用SaxonC处理XSLT样式表编译时遇到了一个奇怪的问题:当传入的XSLT代码存在语法错误(比如缺少开头的<符号)时,compileFromString方法抛出的SaxonApiException错误信息在v12.5版本表现正常,但在v12.7和v12.8版本里出现了大量重复内容的情况,想跟大家请教下相关问题。
不同版本的错误信息对比
SaxonC 12.5(正常输出):
SXXP0003: Error reported by XML parser: Content is not allowed in prolog.SaxonC 12.8(异常重复输出):
Error on line 1 column 1 SXXP0003 Error reported by XML parser: Content is not allowed in prolog. Error SXXP0003 SXXP0003 Error reported by XML parser: Content is not allowed in prolog.具体重复情况:错误码
SXXP0003一共出现了3次,“Error reported by XML parser: Content is not allowed in prolog.”重复了2次,同时还夹杂着多余的换行符。
触发错误的C++代码
我用来测试的C++代码片段如下,核心逻辑是调用compileFromString编译XSLT字符串,捕获异常后记录错误信息:
extern "C" void *compileStylesheet( const void *saxonProcessor_void, const void *xslt30Processor_void, const char *stylesheet_string) { Context *context = nullptr; try { Xslt30Processor *pxslt30Processor = (Xslt30Processor *) xslt30Processor_void; context = new Context(); context->_xsltExecutable = pxslt30Processor->compileFromString(stylesheet_string); } catch (SaxonApiException& e) { formatCerr ("Error in compile_stylesheet", e.getMessage()); context->errMessage = e.getMessage(); } catch (const std::exception& e) { formatCerr ("Error in compile_stylesheet", e.what()); context->errMessage = e.what(); } return context; }
测试用的错误XSLT内容
作为stylesheet_string传入的XSLT代码缺少了开头的<符号,内容如下:
xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> </xsl:stylesheet>
想请教下大家,有没有遇到过类似的问题?这是不是SaxonC v12.7及以上版本的一个已知bug?有没有临时的解决方法可以清理这些重复的错误信息?
内容来源于stack exchange




