Project

Profile

Help

Getting error "XTSE3060: Cannot override template rules in mode m1, because the mode is not public" although the mode is declared as public in the used package

Added by Martin Honnen about 8 years ago

I am trying to familiarize me with packages and @xsl:use-package@ and @xsl:override@. When trying to override a template for a mode with visibility @public@ Saxon 9.7.0.7 EE Java gives me an error

XTSE3060: Cannot override template rules in mode m1, because the mode is not public

so it looks as if I am doing something wrong but I don't know where to change the visibility as the used package has @<xsl:mode name="m1" on-no-match="shallow-copy" visibility="public"/>@.

The package is




	
	
	
	
		
			
			
		
	
	

and I am able to compile and export it successfully

Then the stylesheet trying to use the package is




	
	
		
			
				
					
				
			
		
	
	
	
		
	
	

When I try to run the stylesheet using the package against an input I get the compilation error.

How can I override a template for a public mode from a used package?

A sample input is




	
		
			foo 1
			
				
					foo 2
				
			
		
	


Replies (1)

RE: Getting error "XTSE3060: Cannot override template rules in mode m1, because the mode is not public" although the mode is declared as public in the used package - Added by Michael Kay about 8 years ago

I've reproduced this in a unit test (testPackage/testExportedPackage01), and raised it as a bug at

https://saxonica.plan.io/issues/2908

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);
    (1-1/1)

    Please register to reply