Project

Profile

Help

Bug #2818

closed

xsl:next-match as last instruction in a named template causes IndexOutOfBoundsException

Added by Jason Harrop over 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT 3.0 packages
Sprint/Milestone:
-
Start date:
2016-07-02
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7, trunk
Fix Committed on Branch:
9.7, trunk
Fixed in Maintenance Release:
Platforms:

Description

The TEI docx/from stylesheets contain xsl:next-match at https://github.com/TEIC/Stylesheets/blob/dev/docx/from/wordsections.xsl#L119

This template is triggered by a docx containing:

<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" >
  <w:body>
    <w:p>
      <w:r>
        <w:t>foo</w:t>
      </w:r>
    </w:p>
    <w:p>
      <w:pPr>
        <w:sectPr >
          <w:pgSz w:h="15840" w:w="12240"/>
          <w:pgMar w:gutter="0" w:footer="720" w:header="720" w:left="1440" w:bottom="1440" w:right="1440" w:top="1440"/>
          <w:cols w:space="720"/>
          <w:docGrid w:linePitch="360"/>
        </w:sectPr>
      </w:pPr>
    </w:p>

  </w:body>
</w:document>

With Saxon HE 9.7.0.5 or 9.7.0.6 this causes:

java.lang.IndexOutOfBoundsException: Index: 10, Size: 1
	at java.util.ArrayList.rangeCheck(Unknown Source)
	at java.util.ArrayList.get(Unknown Source)
	at net.sf.saxon.expr.XPathContextMajor.getTargetComponent(XPathContextMajor.java:692)
	at net.sf.saxon.expr.instruct.CallTemplate.processLeavingTail(CallTemplate.java:382)
	at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:835)
	at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:711)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:353)
	at net.sf.saxon.expr.instruct.NextMatch$NextMatchPackage.processLeavingTail(NextMatch.java:208)
	at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:300)
	at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:255)
	at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:835)
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:149)
	at net.sf.saxon.expr.instruct.ForEachGroup.processLeavingTail(ForEachGroup.java:584)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:353)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:456)
	at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:298)
	at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:255)
	at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:835)
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:149)
	at net.sf.saxon.expr.instruct.ForEachGroup.processLeavingTail(ForEachGroup.java:584)
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:653)
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:149)
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:364)
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:311)
	at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:711)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:271)
	at net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:356)
	at net.sf.saxon.expr.instruct.CallTemplate.processLeavingTail(CallTemplate.java:412)
	at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:835)
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:149)
	at net.sf.saxon.expr.instruct.ForEachGroup.processLeavingTail(ForEachGroup.java:584)
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:653)
	at net.sf.saxon.expr.instruct.NamedTemplate.expand(NamedTemplate.java:271)
	at net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:356)
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:364)
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:311)
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:653)
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:149)
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:364)
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:311)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:353)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:456)
	at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:298)
	at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:255)
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:653)
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:149)
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:364)
	at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:311)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:353)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:456)
	at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:298)
	at net.sf.saxon.expr.instruct.ApplyTemplates.process(ApplyTemplates.java:251)
	at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:453)
	at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:149)
	at net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:330)
	at net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:54)
	at net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:304)
	at net.sf.saxon.expr.LetExpression.eval(LetExpression.java:500)
	at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:702)
	at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:653)
	at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:353)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:456)
	at net.sf.saxon.Controller.transformDocument(Controller.java:2270)
	at net.sf.saxon.Controller.transform(Controller.java:1847)
	at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:579)

Interestingly, a workaround is to insert an xsl:message immediately after the xsl:next-match tag.

May be related to the fixed issue 2770


Related issues

Related to Saxon - Bug #3706: Array out of bounds exception results from function in template predicateClosedMichael Kay2018-02-28

Actions

Please register to edit this issue

Also available in: Atom PDF