Capture xsl:message output in java

前端 未结 1 1473
醉话见心
醉话见心 2020-12-16 22:09

I\'m trying to capture xsl:message in java when calling my transform. Below is a snippet of my code.

        final ArrayList err         


        
相关标签:
1条回答
  • If you are using Saxon, then you may need to set the message emitter using setMessageEmitter().

    http://www.saxonica.com/documentation/javadoc/net/sf/saxon/Controller.html

    public void setMessageEmitter(Receiver receiver)

    Set the Receiver to be used for xsl:message output.

    Recent versions of the JAXP interface specify that by default the output of xsl:message is sent to the registered ErrorListener. Saxon does not implement this convention. Instead, the output is sent to a default message emitter, which is a slightly customised implementation of the standard Saxon Emitter interface.

    This interface can be used to change the way in which Saxon outputs xsl:message output.

    Michael Kay has explained why Saxon doesn't output xsl:message according to the JAXP interface, and has suggested two options for obtaining the output:

    ErrorListener was something that was introduced to JAXP at a rather late stage (one of many regrettable occasions where the spec was changed unilaterally to match the Xalan implementation), and I decided not to implement this change as a default behaviour, because it would have been disruptive to existing applications.

    In Saxon, xsl:message output is directed to a Receiver, which you can nominate to the Transformer:

    ((net.sf.saxon.Controller)transformer).setMessageEmitter(....)

    If you want to follow the JAXP model of sending the output to the ErrorListener, you can nominate a Receiver that does this:

    ((net.sf.saxon.Controller)transformer).setMessageEmitter(new net.sf.saxon.event.MessageWarner())

    0 讨论(0)
提交回复
热议问题