mmo
mmo

Reputation: 4246

How to prevent XSLT message function to emit "Warning!"?

I am using ant's xslt-task plus a suitable XSLT script to remove certain nodes from XML documents that we are generating. To get some feedback during processing I added a few message-statements to the script. These work all fine, except that ALL emitted messages have a ": Warning!" prefix. Since the messages are informative only I want/need to get rid of these Warning-prefix to prevent alerting the user who might otherwise think that something is not OK. How can I avoid that prefix? The XSLT message function seems to have no other option than 'terminate="yes"|"no". Can one somehow control that message prefix? And if so: how?

I am using the default xslt task built into ant, i.e. my target reads:

    <xslt in="${source.xml}" out="${output.xml}" style="${stylesheet.xsl}" processor="trax">
</xslt>

with the misc. properties set to point to the appropriate locations. I found that command in some other stack-overflow append.

My ant version reads:

C:\Users\mmo>ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010

Upvotes: 0

Views: 755

Answers (1)

Michael Kay
Michael Kay

Reputation: 163342

I think you're probably using the default Xalan processor, and I'm afraid I can't advise you whether/how its xsl:message processing can be customized.

If you were to switch to using Saxon you would not only get the benefit of doubled productivity by use of XSLT 2.0 instead of 1.0, but you would also get (a) an interface for customising xsl:message output, and (b) membership of an active user community that can answer questions like this.

(Actually, now I think about it, I seem to recall that with Xalan, xsl:message output is sent to the warning() method of the registered ErrorListener, so if you don't want to switch you could try and write an ErrorListener.)

Upvotes: 1

Related Questions