Project

Profile

Help

Bug #5906

closed

C# context item absent

Added by Joel Kalvesmaki almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Documentation
Sprint/Milestone:
-
Start date:
2023-03-07
Due date:
% Done:

100%

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

Description

Hi everyone,

Discovered while developing a .NET 6.0 console application in Visual Studio 2022. In Saxon 12.0 C# via NuGet, I have the following stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0">
    <xsl:variable name="root-el" as="element()" select="/*"/>
    <xsl:template match="/">
        <out>
            <xsl:copy-of select="name($root-el)"/>
        </out>
    </xsl:template>
</xsl:stylesheet>

When used along the model of the C# example, transformer.ApplyTemplates(input, results) produces this:

Error at char 1 in expression in xsl:variable/@select on line 4 column 6 of bill2.xsl:
  XPDY0002  Finding root of tree: the context item is absent
at variable root-el on line 4 column 6 of bill2.xsl:
     invoked by global variable root-el at file:///D:/XPUB_STANDARD/XSLT-Specs/XSLT/XSLT-Bill_TypeSetting/main/bill2.xsl#4
  In template rule with match="/" on line 5 of bill2.xsl
Finding root of tree: the context item is absent

I've replicated the same error in the Saxon resources summarize.xsl by adding $root-el as a global variable and copying the value of its name to the result tree created by the main template. (The template, out of the box, otherwise works like a charm.)

Also seems to happen when I downgrade to version 11.5.

I do not have this error running the code into the Saxon-CS downloaded directly from Saxonica or in other . So there might be something in the NuGet or C# infrastructure that's causing this.

Please register to edit this issue

Also available in: Atom PDF