需要抑制“警告:使用 XSLT 2.0 处理器运行 XSLT 1.0 样式表”在 Tomcat std 输出日志文件中

发布于 2024-10-08 00:09:34 字数 340 浏览 4 评论 0原文

我正在当前项目中使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

南冥有猫 2024-10-15 00:09:34

不能使用 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).

过气美图社 2024-10-15 00:09:34

如果您使用 Saxon 8+ XSLT 2.0 处理器,则可以在调用 Transformer 时抑制此警告,如下所示:

TransformerFactory tf = TransformerFactory.newInstance();
tf.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE);
Transformer t = tf.newTransformer();
t.transform(xmlSource, outputTarget);

如果您在 XMLUnit 中收到错误,您可以将 XSLT 版本设置为 2.0,如下所示:

XMLUnit.setXSLTVersion("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:

TransformerFactory tf = TransformerFactory.newInstance();
tf.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE);
Transformer t = tf.newTransformer();
t.transform(xmlSource, outputTarget);

In case you're getting the error in XMLUnit, you can set XSLT version to 2.0 like this:

XMLUnit.setXSLTVersion("2.0");

Note:

For command-line Saxon invocation, run Saxon like this: saxon -versionmsg:off

書生途 2024-10-15 00:09:34

@rustyx 的答案是如果您使用的是 Saxon API。以防万一您或其他人需要从命令行执行相同的操作,请添加选项:

-versionmsg:关闭

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:

-versionmsg:off

梦里°也失望 2024-10-15 00:09:34

如果您的样式表是使用 XSLT 版本 1.0 编写的,并且您的解析器基于 XSLT 2.0,那么您将看到此警告消息。如果样式表是由您编写的,请尝试进行更改以使其与 XSLT 2.0 兼容。但是,如果样式表不是由我编写的(在我的情况下,它不是由我编写的),那么最简单的解决方案是抑制警告,这样它就不会膨胀您的日志文件。要抑制此版本警告,您必须将其设置为转换工厂的属性。 FeatureKeys 定义了一组非常有用的常量。

TransformerFactory tFactory = TransformerFactory.newInstance();
tFactory.setAttribute(FeatureKeys.VERSION_WARNING, Boolean.FALSE);

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.

TransformerFactory tFactory = TransformerFactory.newInstance();
tFactory.setAttribute(FeatureKeys.VERSION_WARNING, Boolean.FALSE);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文