Bug #5585


SaxonCS reports missing name attribute on xsl:accumulator but then gives System.ArgumentNullException

Added by Martin Honnen about 1 month ago. Updated 11 days ago.

Start date:
Due date:
% Done:


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


Due do a typo I had e.g. xsl:accumulator nme="..." in my XSLT 3 code and found that Saxon EE 11.3 Java reports two messages

Error at xsl:accumulator on line 7 column 77 of sheet1-acc-no-name.xsl:
  XTSE0010  Element must have an @name attribute
Error in xsl:accumulator/@nme on line 7 column 77 of sheet1-acc-no-name.xsl:
  XTSE0090  Attribute @nme is not allowed on element <xsl:accumulator>
Errors were reported during stylesheet compilation

while SaxonCS reports the first message but then gives a System.ArgumentNullException (building the accumulator value?):

Error at xsl:accumulator on line 7 column 6 of sheet1-acc-no-name.xsl:
  XTSE0010  Element must have an @name attribute
System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at Saxon.Impl.Helpers.MapUtils.Get[K,V](IDictionary`2 map, K key)
   at Saxon.Hej.expr.accum.AccumulatorRegistry.getAccumulator(StructuredQName name)
   at decl, PrincipalStylesheetModule top)
   at compilation)
   at source)
   at styleSource, Compilation compilation)
   at config, CompilerInfo compilerInfo, Source source)
   at Saxon.Hej.s9api.XsltCompiler.compile(Source source)
   at Saxon.Hej.Transform.doTransform(String[] args)
Fatal error during transformation: ArgumentNullException: Value cannot be null. (Parameter 'key')
Exiting with code 2

Example XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=""
    <xsl:accumulator nme="foo-collector" as="xs:string?" initial-value="()">
        <xsl:accumulator-rule match="items/foo/text()" select="string()"/>
    <xsl:mode on-no-match="shallow-skip" use-accumulators="#all"/>
    <xsl:template match="data/item/name">
        <xsl:comment select="accumulator-before('foo-collector')"/>

Example XML:

<?xml version="1.0" encoding="UTF-8"?>
            <name>item 1</name>
            <name>item 2</name>
Actions #1

Updated by Michael Kay about 1 month ago

The reason this is crashing on SaxonCS but not on SaxonJ is that in Java, we are using a map implementation for the AccumulatorRegistry that allows a call on get(null), whereas in C#, we are using a map implementation where Get(Null) causes an exception. In other words, it's pure luck that the code doesn't fail in SaxonJ.

We should adopt the usual recovery strategy where a name is missing or invalid of substituting a system-generated name.

Actions #2

Updated by Michael Kay about 1 month ago

  • Status changed from New to Resolved
  • Applies to branch trunk added
  • Fix Committed on Branch 11, trunk added

The patch is in the Java XSLAccumulator code even though the problem only manifests in SaxonCS.

Actions #3

Updated by Debbie Lockett 11 days ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 11.4 added

Bug fix applied in the Saxon 11.4 maintenance release.

Please register to edit this issue

Also available in: Atom PDF