Project

Profile

Help

Bug #5122

closed

Use of fn:all gives System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.

Added by Martin Honnen about 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
XPath conformance
Sprint/Milestone:
-
Start date:
2021-10-09
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
11, trunk
Fix Committed on Branch:
11, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

I am not able to use the new fn:all function with SaxonCS 11 EE, both from XSLT 4 and XPath 4 I run into an exception "System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection."

Stacktrace for some C# test bed to run "XSLT 4":

Unhandled exception. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Saxon.Hej.functions.registry.SefFunction.callFunction(XPathContext context, F name, Sequence[] args)
   at Saxon.Hej.expr.FunctionCall.iterate(XPathContext context)
   at Saxon.Hej.expr.Expression.process(Outputter output, XPathContext context)
   at Saxon.Hej.expr.SystemFunctionCall.process(Outputter output, XPathContext context)
   at Saxon.Hej.expr.instruct.NamedTemplate.expand(Outputter output, XPathContext context)
   at Saxon.Hej.trans.XsltController.callTemplate(StructuredQName initialTemplateName, Receiver out)
   at Saxon.Hej.s9api.Xslt30Transformer.callTemplate(QName templateName, Destination destination)
   at Saxon.Api.Xslt30Transformer.CallTemplate(QName templateName, IDestination destination)
   at SaxonCSRunXSLT4.Program.Main(String[] args) in C:\Users\marti\source\repos\SaxonCSRunXSLT4\SaxonCSRunXSLT4\Program.cs:line 37

It is run against the XSLT

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="4.0"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="#all"
    expand-text="yes">
    
    <xsl:output method="adaptive" indent="yes" build-tree="no"/>
    
    <xsl:template match="/" name="xsl:initial-template">
        <xsl:sequence select="all((1, 3, 7), ->{. mod 2 = 1})"/>
    </xsl:template>
    
</xsl:stylesheet>

C# code:

using System;
using System.IO;
using Saxon.Api;

namespace SaxonCSRunXSLT4
{
    class Program
    {
        static void Main(string[] args)
        {
            var processor = new Processor();

            processor.SetProperty<bool>(Feature<bool>.TIMING, true);

            var xsltCompiler = processor.NewXsltCompiler();

            xsltCompiler.XsltLanguageVersion = "4.0";

            XsltExecutable xsltExecutable;

            using (var fs = File.OpenRead(args[0]))
            {
                xsltExecutable = xsltCompiler.Compile(fs);
            }

            Xslt30Transformer xslt40Transformer = xsltExecutable.Load30();

            if (args.Length == 2)
            {
                using (var fs = File.OpenRead(args[1]))
                {
                    xslt40Transformer.ApplyTemplates(fs, processor.NewSerializer(Console.Out));
                }
            }
            else
            {
                xslt40Transformer.CallTemplate(null, processor.NewSerializer(Console.Out));
            }
        
            Console.WriteLine();
        }
    }
}

Please register to edit this issue

Also available in: Atom PDF