Looking at the code, I suspect this can happen if (a) you don't initialize your MessageEmitter by calling setWriter() or setOutputStream(), and (b) the content of the <xsl:message> instruction is empty. I'll fix this.
 
Michael Kay
http://www.saxonica.com/


From: Vanfleet, David [mailto:david.vanfleet@siemens.com]
Sent: 02 December 2008 19:36
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Error using custom MessageEmitter

Hi All,

 

I just upgraded Saxonb from 8.7.3 to 9.1.0.3 and I now get the error below when I use a custom MessageEmitter.

 

Line 14 in the MessageEmitter class is the “writer.write('\n');” line in the following endDocument method.

 

 

    public void endDocument() throws XPathException {

        try {

            writer.write('\n');

        } catch (java.io.IOException err) {

            throw new XPathException(err);

        }

        super.close();

    }

 

 

Is this a bug, or do I need to make some changes in my implementation? Any help here would be appreciated.

 

Thanks,

David Vanfleet

david.vanfleet@siemens.com

 

 

Exception in thread "Thread-3" java.lang.NullPointerException

      at net.sf.saxon.event.MessageEmitter.endDocument(MessageEmitter.java:14)

      at net.sf.saxon.event.TreeReceiver.endDocument(TreeReceiver.java:122)

      at net.sf.saxon.event.ProxyReceiver.endDocument(ProxyReceiver.java:106)

      at net.sf.saxon.instruct.Message.processLeavingTail(Message.java:219)

      at net.sf.saxon.instruct.Choose.processLeavingTail(Choose.java:686)

      at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203)

      at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:345)

      at net.sf.saxon.instruct.ApplyTemplates.apply(ApplyTemplates.java:210)

      at net.sf.saxon.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:174)

      at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556)

      at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)

      at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:296)

      at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203)

      at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:345)

      at net.sf.saxon.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:527)

      at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:317)

      at net.sf.saxon.instruct.ApplyTemplates.apply(ApplyTemplates.java:210)

      at net.sf.saxon.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:174)

      at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556)

      at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)

      at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:296)

      at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203)

      at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:345)

      at net.sf.saxon.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:527)

      at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:317)

      at net.sf.saxon.instruct.ApplyTemplates.apply(ApplyTemplates.java:210)

      at net.sf.saxon.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:174)

      at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556)

      at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)

      at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:296)

      at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203)

      at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:345)