Hi all,

It seems I have a bug with saxonPE (v9.5) when using syntax "1" : 
<xsl:number count="*[predicate1][predicate1]">

It works when using syntax "2" :
<xsl:number count="*[(predicate1) and (predicate1)]">
instead.

This happens in a xsl:function where each predicates uses variables.

With syntax "1" and variable in predicate1 is $id, I get this error message : 

java.lang.ArrayIndexOutOfBoundsException: Local variable $id has not been allocated a stack 

This is the "real" function :

<xsl:function name="ecf2ncx:get-num-toc" as="xs:string?">
<xsl:param name="e" as="element()"/>
<xsl:variable name="name" select="local-name($e)"/>
<!-- Renumérotation à partir d'une entrée hiérarchiquement plus importante -->
<xsl:variable name="id" select="generate-id($e/parent::*)"/>
<xsl:choose>
<xsl:when test="$e/@toc-addnum='true' or $e/@toc-addnum='single'">
<xsl:number level="single" select="$e" count="*[generate-id(parent::*)=$id and local-name(.)=$name and @toc-addnum=$e/@toc-addnum]"
format="{$e/@toc-addnum-format}"/>
<!--BUG SAXON ? : on aurait pu écrire count="*[generate-id(parent::*)=$id][local-name(.)=$name][@toc-addnum=$e/@toc-addnum]" mais cela génère un bogue saxon-->
</xsl:when>
<xsl:when test="$e/@toc-addnum='any'">
<!--@toc-addnum-format possibles sont "1", "01", "a", "A", "i", "I" (idem xsl:number/@format).-->
<xsl:number level="any" select="$e" count="*[ local-name() = $name and @toc-addnum = $e/@toc-addnum ]"
format="{$e/@toc-addnum-format}"/>
</xsl:when>
</xsl:choose>
</xsl:function>


I ran the xslt with xproc and last calabash 

I'm really sorry I don't have time for now to write an unit test but I hope there's enough information here, maybe the problem is known ?

This is the whole stack trace :
SEVERE: Pipeline failed: java.lang.ArrayIndexOutOfBoundsException: Local variable $id has not been allocated a stack frame
java.lang.ArrayIndexOutOfBoundsException: Local variable $id has not been allocated a stack frame slot
        at net.sf.saxon.expr.LocalVariableReference.evaluateVariable(LocalVariableReference.java:102)
        at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:453)
        at net.sf.saxon.expr.Atomizer.iterate(Atomizer.java:294)
        at net.sf.saxon.expr.GeneralComparison.effectiveBooleanValue(GeneralComparison.java:616)
        at net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:139)
        at net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:131)
        at net.sf.saxon.tree.util.Navigator.getNumberSingle(Navigator.java:357)
        at net.sf.saxon.expr.instruct.NumberInstruction.evaluateItem(NumberInstruction.java:574)
        at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:337)
        at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:35)
        at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:275)
        at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:34)
        at net.sf.saxon.expr.instruct.Choose.evaluateItem(Choose.java:895)
        at net.sf.saxon.expr.LetExpression.evaluateItem(LetExpression.java:417)
        at net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:326)
        at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:368)
        at net.sf.saxon.expr.UserFunctionCall.callFunction(UserFunctionCall.java:478)
        at net.sf.saxon.expr.UserFunctionCall.evaluateItem(UserFunctionCall.java:429)
        at net.sf.saxon.functions.StringFn.evaluateItem(StringFn.java:141)
        at net.sf.saxon.functions.StringFn.evaluateItem(StringFn.java:32)
        at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:337)
        at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:35)
        at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:275)
        at net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:34)
        at net.sf.saxon.expr.instruct.Choose.evaluateItem(Choose.java:895)
        at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:337)
        at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:35)
        at net.sf.saxon.functions.Concat.evaluateItem(Concat.java:107)
        at net.sf.saxon.functions.Concat.evaluateAsString(Concat.java:96)
        at net.sf.saxon.expr.instruct.SimpleNodeConstructor.processLeavingTail(SimpleNodeConstructor.java:215)
        at net.sf.saxon.expr.instruct.ValueOf.processLeavingTail(ValueOf.java:254)
        at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Choose.java:860)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:431)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:373)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:431)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:373)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:431)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:373)
        at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:239)
        at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1057)
        at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:281)
        at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:241)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:431)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:373)
        at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:239)
        at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1057)
        at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:281)
        at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:241)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:138)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:431)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:373)
        at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:239)
        at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1057)
        at net.sf.saxon.trans.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:65)
        at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1045)
        at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:281)
        at net.sf.saxon.expr.instruct.ApplyTemplates.process(ApplyTemplates.java:237)
        at net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:323)
        at net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:56)
        at net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:326)
        at net.sf.saxon.expr.LetExpression.eval(LetExpression.java:398)
        at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:604)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
        at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:613)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
        at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:613)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
        at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:613)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:660)
        at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:613)
        at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:239)
        at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1057)
        at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:519)
        at net.sf.saxon.Controller.transformDocument(Controller.java:2082)
        at net.sf.saxon.Controller.transform(Controller.java:1903)
        at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:450)
        at com.xmlcalabash.library.XSLT.run(Unknown Source)
        at com.xmlcalabash.runtime.XAtomicStep.run(Unknown Source)
        at com.xmlcalabash.runtime.XCompoundStep.run(Unknown Source)
        at com.xmlcalabash.runtime.XCompoundStep.run(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.doRun(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.run(Unknown Source)
        at com.xmlcalabash.runtime.XPipelineCall.run(Unknown Source)
        at com.xmlcalabash.runtime.XCompoundStep.run(Unknown Source)
        at com.xmlcalabash.runtime.XChoose.run(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.doRun(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.run(Unknown Source)
        at com.xmlcalabash.runtime.XPipelineCall.run(Unknown Source)
        at com.xmlcalabash.runtime.XCompoundStep.run(Unknown Source)
        at com.xmlcalabash.runtime.XCompoundStep.run(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.doRun(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.run(Unknown Source)
        at com.xmlcalabash.runtime.XPipelineCall.run(Unknown Source)
        at com.xmlcalabash.runtime.XCompoundStep.run(Unknown Source)
        at com.xmlcalabash.runtime.XChoose.run(Unknown Source)
        at com.xmlcalabash.runtime.XCompoundStep.run(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.doRun(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.run(Unknown Source)
        at com.xmlcalabash.runtime.XPipelineCall.run(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.doRun(Unknown Source)
        at com.xmlcalabash.runtime.XPipeline.run(Unknown Source)
        at com.xmlcalabash.drivers.Main.run(Unknown Source)
        at com.xmlcalabash.drivers.Main.run(Unknown Source)
        at com.xmlcalabash.drivers.Main.main(Unknown Source)


--
Matthieu Ricaud-Dussarget
IGS-CP - Développeur XML
05 45 37 09 49