Skip to content

SaxonJS 3.0.0-beta2: xslt3-he crashes with 'Internal error: assertion failed' #13

@ThePlenkov

Description

@ThePlenkov

Description

When I run an XSLT 3.0 stylesheet that builds a JSON map/array structure using SaxonJS 3.0.0-beta2 (via the xslt3-he CLI), the compiler aborts with Internal error: assertion failed. The same logic works with SaxonJS 2.x.

Steps to Reproduce

  1. Save the following stylesheet as adt-to-json.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:pak="http://www.sap.com/adt/packages"
  xmlns:adtcore="http://www.sap.com/adt/core"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:pkg="urn:pkg"
  exclude-result-prefixes="xs pak adtcore atom pkg">

  <xsl:output method="json" indent="yes" encoding="UTF-8"/>

  <xsl:function name="pkg:boolean" as="xs:boolean">
    <xsl:param name="value" as="xs:string?"/>
    <xsl:sequence select="lower-case($value) = ('true', '1', 'x')"/>
  </xsl:function>

  <xsl:template match="/">
    <xsl:sequence select="pkg:package-map(/pak:package)"/>
  </xsl:template>

  <xsl:function name="pkg:package-map" as="map(*)">
    <xsl:param name="pkg" as="element(pak:package)"/>

    <xsl:sequence select="
      map {
        'core': map {
          'name': string($pkg/@adtcore:name),
          'description': string($pkg/@adtcore:description)
        },
        'package': map {
          'attributes': map {
            'packageType': string($pkg/pak:attributes/@pak:packageType),
            'isPackageTypeEditable': pkg:boolean($pkg/pak:attributes/@pak:isPackageTypeEditable)
          },
          'links': array {
            for $link in $pkg/atom:link
            return map {
              'rel': string($link/@rel),
              'href': string($link/@href),
              'title': string($link/@title),
              'type': string($link/@type)
            }
          },
          'useAccesses': map {
            'isVisible': pkg:boolean($pkg/pak:useAccesses/@pak:isVisible)
          }
        }
      }
    "/>
  </xsl:function>

</xsl:stylesheet>
  1. Save this minimal source XML as package.xml:
<pak:package xmlns:pak="http://www.sap.com/adt/packages" xmlns:adtcore="http://www.sap.com/adt/core" xmlns:atom="http://www.w3.org/2005/Atom"
  adtcore:responsible="PPLENKOV" adtcore:masterLanguage="EN" adtcore:name="$ABAPGIT_EXAMPLES" adtcore:type="DEVC/K"
  adtcore:changedAt="2025-11-09T00:00:00Z" adtcore:version="active" adtcore:createdAt="2025-11-09T00:00:00Z"
  adtcore:changedBy="PPLENKOV" adtcore:createdBy="PPLENKOV" adtcore:description="Abapgit examples"
  adtcore:descriptionTextLimit="60" adtcore:language="EN">
  <atom:link href="versions" rel="http://www.sap.com/adt/relations/versions" title="Historic versions"/>
  <pak:attributes pak:packageType="development" pak:isPackageTypeEditable="false"
    pak:isAddingObjectsAllowed="false" pak:isAddingObjectsAllowedEditable="true" pak:isEncapsulated="false"
    pak:isEncapsulationEditable="false" pak:isEncapsulationVisible="false" pak:recordChanges="false"
    pak:isRecordChangesEditable="false" pak:isSwitchVisible="false" pak:languageVersion=""
    pak:isLanguageVersionVisible="true" pak:isLanguageVersionEditable="true"/>
  <pak:useAccesses pak:isVisible="false"/>
</pak:package>
  1. Run the CLI shipped with SaxonJS 3:
npx xslt3-he@3.0.0-beta2 -xsl:adt-to-json.xsl -s:package.xml -o:out.json

Actual result

The CLI exits with:

Internal error: assertion failed
    at SaxonJS3N.js:3755:396
    ... (full stack omitted for brevity)

No output is produced.

Expected result

The stylesheet should serialize the JSON map/array just as SaxonJS 2.x and SaxonJ 10/11 do.

Environment

  • xslt3-he / saxonjs-he: 3.0.0-beta2 (npm install)
  • Node.js 24.10.0 on Ubuntu 22.04 (WSL)

Let me know if you need the full stack trace or the original, larger stylesheet—the reproducer above consistently fails for me.

Generated by Codex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions