开发者

Need to suppress "Warning: running an XSLT 1.0 stylesheet with an XSLT 2.0 processor" in Tomcat std out log file

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.


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).


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


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


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜