Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 318
user542447 Avatar asked Dec 14 '10 23:12

user542447


People also ask

Is XSLT 2.0 backward compatibility?

The XSLT 2.0 engine is backwards compatible. The only time the backwards compatibility of the XSLT 2.0 engine comes into effect is when using the XSLT 2.0 engine to process an XSLT 1.0 stylesheet.

What is the purpose of an XSLT stylesheet?

XSLT is most often used to convert data between different XML schemas or to convert XML data into web pages or PDF documents.

What is Number () in XSLT?

Specifies the format pattern. Here are some of the characters used in the formatting pattern: 0 (Digit) # (Digit, zero shows as absent)


2 Answers

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

like image 131
Dimitre Novatchev Avatar answered Oct 31 '22 09:10

Dimitre Novatchev


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

like image 28
rustyx Avatar answered Oct 31 '22 09:10

rustyx