Project

Profile

Help

Bug #3960

closed

Transformation API: supplying lexical XML input and setting the global context item

Added by Michael Kay over 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Category:
s9api API
Sprint/Milestone:
-
Start date:
2018-10-10
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9
Fix Committed on Branch:
9.9
Fixed in Maintenance Release:
Platforms:

Description

XSLT 3.0 has separated the concept of the "initial match selection" and the "global context item"; they no longer need to be the same thing.

Nevertheless, many stylesheets follow the traditional pattern of a single principal source document that is available both as the initial match selection (for <xsl:template match="/">) and as the global context item (for reference within global variables).

The problem is that in some APIs (notably, the fn:transform interface and the s9api Xslt30Transformer) these have to be supplied separately. The global context item can only be supplied as a node, which means the tree has to be built under application control, and building the tree under application control makes it hard to ensure that stylesheet-defined whitespace stripping is applied during parsing. We handle this OK for the Transform command line, but it's messy: the call

builder.setWhitespaceStrippingPolicy(sheet.getWhitespaceStrippingPolicy());

isn't exactly intuitive to users. If you're calling fn:transform() from XSLT or XQuery then this mechanism isn't available anyway.

I'm currently looking at the XSLT test driver written in XSLT (in xsl30-tests/runner) which invokes the transformation using fn:transform(). In cases where validation is requested, it passes the source document to fn:transform using our Saxon-specific source-location property. This invokes the transformation via Xslt30Transformer.applyTemplates(source, destination), which does not set the global context item. But some of the tests, such as as-1701, are expecting the global context item to be set. At present you can't set the global context item unless you take charge of document building, and doing the document building externally in a way that respects the stylesheet's whitespace policy isn't possible in the fn:transform interface.

Please register to edit this issue

Also available in: Atom PDF