Here is the full stack trace, but I've isolated it to processing of content from my MessageListener, which isn't very fancy, just set's out messages to go to log4j, but even sending to System.out.println, I get the failure. If I remove the Transformer.setMessageListener and let the default listener function, there is not failure. Note that this doesn't fail on all documents we process, only some. Here is the stack trace and the MessageListener code:
 

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 860

at net.sf.saxon.tinytree.TinyParentNodeImpl.getStringValue(TinyParentNodeImpl.java:64)

at net.sf.saxon.tinytree.TinyParentNodeImpl.getStringValue(TinyParentNodeImpl.java:30)

at net.sf.saxon.s9api.XdmItem.getStringValue(XdmItem.java:71)

at gov.irs.map.composition.compEngine.filters.XSLTMessages.message(XSLTMessages.java:53)

at net.sf.saxon.s9api.MessageListenerProxy.write(MessageListenerProxy.java:103)

at net.sf.saxon.event.SequenceWriter.append(SequenceWriter.java:310)

at net.sf.saxon.s9api.MessageListenerProxy.append(MessageListenerProxy.java:87)

at net.sf.saxon.event.SequenceWriter.endDocument(SequenceWriter.java:112)

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.Block.processLeavingTail(Block.java:556)

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

at net.sf.saxon.instruct.Template.expand(Template.java:220)

at net.sf.saxon.instruct.CallTemplate.process(CallTemplate.java:257)

at net.sf.saxon.instruct.CallTemplate.processLeavingTail(CallTemplate.java:281)

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

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

at net.sf.saxon.expr.LetExpression.process(LetExpression.java:378)

at net.sf.saxon.instruct.ForEach.processLeavingTail(ForEach.java:321)

at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:549)

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

at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:549)

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

at net.sf.saxon.instruct.Template.expand(Template.java:220)

at net.sf.saxon.instruct.CallTemplate.process(CallTemplate.java:257)

at net.sf.saxon.instruct.CallTemplate.processLeavingTail(CallTemplate.java:281)

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

at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:549)

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

at net.sf.saxon.instruct.Template.expand(Template.java:220)

at net.sf.saxon.instruct.CallTemplate.process(CallTemplate.java:257)

at net.sf.saxon.instruct.CallTemplate.processLeavingTail(CallTemplate.java:281)

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.Block.processLeavingTail(Block.java:556)

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.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$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.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.Choose.processLeavingTail(Choose.java:686)

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.Block.processLeavingTail(Block.java:556)

at net.sf.saxon.instruct.Template.expand(Template.java:220)

at net.sf.saxon.instruct.CallTemplate.process(CallTemplate.java:257)

at net.sf.saxon.instruct.CallTemplate.processLeavingTail(CallTemplate.java:281)

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

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.Block.processLeavingTail(Block.java:556)

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

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

at net.sf.saxon.Controller.transformDocument(Controller.java:1807)

at net.sf.saxon.Controller.transform(Controller.java:1621)

at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:231)

at gov.irs.map.composition.compEngine.filters.GenerateFO.run(GenerateFO.java:178)

at gov.irs.map.composition.compEngine.CompEngine.compose(CompEngine.java:328)

at gov.irs.map.composition.compEngine.BootStrap.main(BootStrap.java:136)

package gov.irs.map.composition.compEngine.filters;
 
import gov.irs.map.composition.compEngine.CompParm;
import gov.irs.map.composition.compEngine.utils.FilePkg;
 
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
 
import javax.xml.transform.SourceLocator;
 
import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
 
import net.sf.saxon.s9api.MessageListener;
import net.sf.saxon.s9api.XdmNode;
 
public class XSLTMessages implements MessageListener {
 private static Logger logger = Logger.getLogger("gov.irs.map.composition.compEngine.filters.XSLTMessages");
 
 public XSLTMessages(CompParm proc, FilePkg fp) {
  FileAppender fa = null;
  FileAppender procAppender = (FileAppender) logger.getAppender(fp.getProcessBaseName() + ".log");
  if (procAppender == null) {
   File logFile = new File(fp.getProcessBaseName() + ".log");
   PatternLayout pa = new PatternLayout("[%d{dd MMM yyyy HH:mm:ss,SSS}] [%-5p] [%C{1}]: %m%n");
   fa = null;
   try {
    fa = new FileAppender(pa, logFile.getAbsolutePath());
    fa.setName(fp.getProcessBaseName() + ".log");
   } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
   }
   
   logger.addAppender(fa);
  }
  if (proc.getDebugLevel() == 1) {
   logger.setLevel(Level.WARN);
  }
  else if (proc.getDebugLevel() > 1) {
   logger.setLevel(Level.ALL);
  }
  else {
   logger.setLevel(Level.INFO);
  }
 }
 
 public void message(XdmNode content, boolean terminate, SourceLocator locator) {
  if (content != null) {
  System.out.println(locator.getSystemId() + ": " + content.getStringValue());
  //logger.info(content.getStringValue());
  }
  else {
   
  }
 }
 
}
Steve Cuzner
401-996-4035
 


From: Michael Kay [mailto:mike@saxonica.com]
Sent: Tuesday, May 15, 2012 5:25 PM
To: saxon-help@lists.sourceforge.net
Subject: Re: [saxon] How to specify standard tree from the api



On 15/05/2012 20:08, Cuzner Stephen P wrote:
We have run ito a problem where we get an

java.lang.ArrayIndexOutOfBoundsException: 860

at net.sf.saxon.tinytree.TinyParentNodeImpl.getStringValue(TinyParentNodeImpl.java:64)

Well, that's a new one, and I would certainly like to know what you're doing to cause that failure. Could you provide some more information, ideally enough to reproduce the problem, but at the very least, the full stack trace? This is a path that's used zillions of times so there must be something quite unusual going on.

 

So I'm thinking of switching over to the standard tree model. There is documentation on specifying the tree model from the command line, but only the reference that it can be done through the api.

You can set the tree model on the s9api DocumentBuilder using the setTreeModel() method.

Michael Kay
Saxonica

I can see that it is related to Controller, but I'm not sure how it all fits together. The basic flow of my application is

Processor saxonProc = new Processor(false);

DocumentBuilder docBuilder = saxonProc.newDocumentBuilder();

Serializer serializedOutput = new Serializer();

serializedOutput.setOutputFile(foFile);

XsltCompiler xsltCompiler = saxonProc.newXsltCompiler();

foStyle = xsltCompiler.compile(stylesheet.asSource());

XsltTransformer foTransformer = foStyle.load();

foTransformer.setDestination(serializedOutput);

foTransformer.setInitialContextNode(input);

foTransformer.transform();

Where in this sequence would I create the controller and set it to use. Is there an easier way to do this? Is there example code available?

 
Steve Cuzner
 


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help