[xsl] Re: What is the default global context item?

Subject: [xsl] Re: What is the default global context item?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 4 May 2020 10:22:41 -0000
It depends on the processor's API.

For Saxon, we effectively have two kinds of API: legacy APIs where the
"initial match selection" and "global context item" are the same thing, and
3.0-specific APIs where they are set independently. You need to read the specs
for the particular API you are using. By default the global context item is
undefined ("absent").

Some of the 3.0 changes were for streaming - in particular the option to have
an initial match selection (typically the streamed input document) without
having a global context item.

But it's more complex than that: 2.0 allows you to set a global context item
for named-template invocation (where there's no initial match selection), and
even in 1.0, there's some rule somewhere (can't remember if it's in the
language spec or in some API spec) whereby if the initial match selection is a
non-document node, then the global context item is the document root of the
tree containing that node.

Michael Kay

> On 4 May 2020, at 10:53, Erik Siegel <erik@xxxxxxxxxxx> wrote:
> Hi all (and maybe especially @Michael Kay <mailto:mike@xxxxxxxxxxxx>)
> In implementing XSLT 3 conversions for XProc 3.0 pipelines we ran into this
> What is the global context item for an XSLT 3.0 stylesheet when none is set
> Ibve tried to find it in the XSLT 3 spec but found it hard to find the
definite answer. In practice however (for XML conversions)  I noticed itbs
the document-node of the main input document. But is that because the XSLT 3
spec says so or just a convenient default of Saxon?
> Hope anyone can help us out,
> Erik Siegel

Current Thread