Project

Profile

Help

Bug #2908

closed

Overriding template rules in a package loaded from a stylesheet export file

Added by Michael Kay almost 8 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT 3.0 packages
Sprint/Milestone:
-
Start date:
2016-08-26
Due date:
% Done:

100%

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

Description

Raised by Martin Honnen here:

https://saxonica.plan.io/boards/3/topics/6527

The problem occurs when an overriding package tries to create a template rule in a mode declared in a used package, which has been loaded from an export file.

Actions #1

Updated by Michael Kay almost 8 years ago

  • Status changed from New to In Progress

The error message is produced because mode.getDeclaredVisibility() on the reloaded mode is null (although the component visibility is public).

I'm not quite sure why it is looking at the declared visibility, but it seems wrong that after export/import the value is different from the original.

Actions #2

Updated by Michael Kay almost 8 years ago

The code works if the package is loaded from source, but not if it is loaded from an export file.

It appears that loading separately-compiled packages from export files has not been very thoroughly tested: we've tested export quite intensively against complete stylesheets, but not against library packages on their own.

(I also noted while developing this test that while APIs for loading the main stylesheet will accept either source XSLT or an export file, the same is not true for APIs that load library packages).

The test I am using to run this is:

            Processor processor = new Processor(true);
            XsltCompiler compiler = processor.newXsltCompiler();
            File file = new File("...../xslt30-test-B/tests/decl/override/override-m-021-base.sef");
            XsltPackage pack = compiler.loadLibraryPackage(file.toURI());
            System.err.println("Package loaded from " + file.getAbsolutePath());
            compiler.importPackage(pack);
            XsltExecutable exec = compiler.compile(new StreamSource(new File("...../xslt30-test-B/tests/decl/override/override-m-021.xsl")));
            DocumentBuilder db = processor.newDocumentBuilder();
            XdmNode root = db.build(new File("...../xslt30-test-B/tests/decl/override/override-m-021.xml"));
            Xslt30Transformer trans = exec.load30();
            StringWriter out = new StringWriter();
            Serializer ser = processor.newSerializer(out);
            trans.applyTemplates(root, ser);
Actions #3

Updated by Michael Kay almost 8 years ago

I think the code should be checking for the visibility of the Mode component, not for its declaredVisibility. The two can be different, for example, as a result of xsl:expose or xsl:accept. The declared visibility is not captured in the export file, and I don't think it should be, because it is of no concern to a using package.

Actions #4

Updated by Michael Kay almost 8 years ago

I have made the change suggested, and it works for this test without apparently causing any regression.

I have also changed the XSLT30 test suite driver so that if -export is specified, any packages named in the environment are exported and reimported before use.

This has led to three tests failing, where the package defines a decimal format: test cases override-misc-004, -005, and -006.

Actions #5

Updated by Michael Kay almost 8 years ago

  • Fix Committed on Branch 9.7, 9.8 added

Patch committed for 9.7 and 9.8.

Leaving open to investigate the tests that now fail under -export.

Actions #6

Updated by Michael Kay almost 8 years ago

  • Status changed from In Progress to Resolved

Closing now: a new bug (bug #2910) has been raised for the new problems found during the investigation.

Actions #7

Updated by O'Neil Delpratt almost 8 years ago

  • % Done changed from 0 to 100

Bug fix applied in the Saxon 9.7.0.8 maintenance release.

Actions #8

Updated by O'Neil Delpratt almost 8 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.7.0.8 added
Actions #9

Updated by O'Neil Delpratt about 7 years ago

  • Applies to branch deleted (9.8)
  • Fix Committed on Branch trunk added
  • Fix Committed on Branch deleted (9.8)

Please register to edit this issue

Also available in: Atom PDF