需要抑制“警告:使用 XSLT 2.0 处理器运行 XSLT 1.0 样式表”在 Tomcat std 输出日志文件中
我正在当前项目中使用 xslt 转换。原始 xslt 是以样式表 1.0 格式编写的。该项目在 Apache Tomcat 服务器上运行。在服务器的输出日志中,警告:
Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
不断地从 Tomcat 打印到标准输出日志。我尝试将样式表版本号更改为“2.0”,但我的项目的部分内容在变压器之后没有获得正确的数据。我希望解决此问题的唯一原因是日志文件占用了太多内存空间。那么有人知道如何抑制特定 Tomcat 服务器的警告吗?最好抑制这一特定警告,但任何意见都非常感激。谢谢。
I am using xslt transformations on my current project. The original xslts were written in stylesheet 1.0 format. The project is run on Apache Tomcat server. In the output logs from the server, the warning:
Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
is constantly printing to the std out logs from Tomcat. I tried changing the stylesheet version number to "2.0" but parts of my project is not getting the correct data after the to the transformer. Only reason why I wish to fix this issue is because the log file is taking up too much memory space. So does anybody know how to suppress the warning for specific Tomcat server? Suppressing this one specific warning would be preferred but any opinions is much appreciated. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不能使用 XSLT 1.0 处理器运行转换吗?
如果答案是否定的,那么使用 XSLT 2.0 处理器运行 XSLT 1.0 转换并不是一个好主意。
我的建议是将
的版本属性更改为 2.0 并调试代码,以便生成正确的结果。这消除了警告以及向后兼容模式的任何不良副作用(例如仍然使用 XPath 2.0 XDM)。Can't you run the transformation with an XSLT 1.0 processor?
If the answer is negative, then it is not a good idea to run an XSLT 1.0 transformation with an XSLT 2.0 processor.
My recommendation is to change the version attribute of
<xsl:stylesheet>
to 2.0 and to debug the code so that the correct results are produced. This eliminates the warning and also any bad side efects of the backwards compatibility mode (such as still using the XPath 2.0 XDM).如果您使用 Saxon 8+ XSLT 2.0 处理器,则可以在调用 Transformer 时抑制此警告,如下所示:
如果您在 XMLUnit 中收到错误,您可以将 XSLT 版本设置为 2.0,如下所示:
注意:
对于命令-line Saxon 调用,像这样运行 Saxon:
saxon -versionmsg:off
In case you're using Saxon 8+ XSLT 2.0 processor, you can suppress this warning when invoking the Transformer like this:
In case you're getting the error in XMLUnit, you can set XSLT version to 2.0 like this:
Note:
For command-line Saxon invocation, run Saxon like this:
saxon -versionmsg:off
@rustyx 的答案是如果您使用的是 Saxon API。以防万一您或其他人需要从命令行执行相同的操作,请添加选项:
The answer from @rustyx is if you're using the Saxon API. Just in case you, or some else, needs the same thing from the command line, add the option:
如果您的样式表是使用 XSLT 版本 1.0 编写的,并且您的解析器基于 XSLT 2.0,那么您将看到此警告消息。如果样式表是由您编写的,请尝试进行更改以使其与 XSLT 2.0 兼容。但是,如果样式表不是由我编写的(在我的情况下,它不是由我编写的),那么最简单的解决方案是抑制警告,这样它就不会膨胀您的日志文件。要抑制此版本警告,您必须将其设置为转换工厂的属性。 FeatureKeys 定义了一组非常有用的常量。
If your stylesheet is written using XSLT version 1.0 and your parser is based on XSLT 2.0, then you will see this warning message. If the stylesheet is written by you then try to make changes so that it is compatible with XSLT 2.0. But if the styesheet is not written by (in my case it was not written by me), then the easiest solution would be to suppress the warning, so that it will not bloat up your log files. To suppress this version warning, you have to set it as an attribute to the transformation factory. FeatureKeys defines a set of constants which are very helpful.