Bug #2908
closedOverriding template rules in a package loaded from a stylesheet export file
100%
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.
Updated by Michael Kay about 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.
Updated by Michael Kay about 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);
Updated by Michael Kay about 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.
Updated by Michael Kay about 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.
Updated by Michael Kay about 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.
Updated by Michael Kay about 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.
Updated by O'Neil Delpratt about 8 years ago
- % Done changed from 0 to 100
Bug fix applied in the Saxon 9.7.0.8 maintenance release.
Updated by O'Neil Delpratt about 8 years ago
- Status changed from Resolved to Closed
- Fixed in Maintenance Release 9.7.0.8 added
Updated by O'Neil Delpratt over 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