Project

Profile

Help

Bug #3367

closed

function not found inside xslt package

Added by Jiri Dolejsi over 7 years ago. Updated over 7 years ago.

Status:
Duplicate
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
2017-07-31
Due date:
% Done:

0%

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

Description

Trivial example:

I have packageA,

package, which uses packageA

transform, which call function from packageB.

packageA:

<xsl:package name="http://www.ctk.cz/A/" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:pA="http://www.ctk.cz/A/">

	<xsl:function name="pA:helper" as="xs:string">
		<xsl:sequence select="'Prague'"/>
	</xsl:function>

	<xsl:function name="pA:fA" as="xs:string" visibility="public">
		<xsl:sequence select="pA:helper()"/>
	</xsl:function>
</xsl:package>

PackageB:

<xsl:package name="http://www.ctk.cz/B/" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:pA="http://www.ctk.cz/A/" xmlns:pB="http://www.ctk.cz/B/">
	<xsl:use-package name="http://www.ctk.cz/A/"/>
	<xsl:function name="pB:fB" as="xs:string" visibility="public">
		<xsl:sequence select="pA:fA()"/>
	</xsl:function>
</xsl:package>

transform:

<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version="3.0"
                    xmlns:xs="http://www.w3.org/2001/XMLSchema"
                    xmlns:pB="http://www.ctk.cz/B/">
                    
                    <xsl:use-package name='http://www.ctk.cz/B/'/>
                    <xsl:template name="xsl:initial-template" as="xs:string">
                        <xsl:sequence select="pB:fB()"/>
                        </xsl:template>
                 </xsl:stylesheet>

C# function to call transform:

Processor processor = new Processor(true);

            XsltCompiler xsltCompiler = processor.NewXsltCompiler();
            xsltCompiler.XsltLanguageVersion = "3.0";
            XsltPackage packageA;
            using (Stream stream = File.OpenRead("D:/MyDownloads/mrs2/packageA.xslt"))
                packageA = xsltCompiler.CompilePackage(stream);

            xsltCompiler = processor.NewXsltCompiler();
            xsltCompiler.XsltLanguageVersion = "3.0";
            xsltCompiler.ImportPackage(packageA);
            XsltPackage packageB;
            using (Stream stream = File.OpenRead("D:/MyDownloads/mrs2/packageB.xslt"))
                packageB = xsltCompiler.CompilePackage(stream);

            xsltCompiler = processor.NewXsltCompiler();
            xsltCompiler.XsltLanguageVersion = "3.0";
            xsltCompiler.ImportPackage(packageA);
            xsltCompiler.ImportPackage(packageB);
            XsltExecutable exec = xsltCompiler.Compile(new Uri("file:///D:/MyDownloads/mrs2/test.xslt"));
            XsltTransformer transf = exec.Load();
            Serializer serializer = new Serializer();
            StringWriter sw = new StringWriter();
            serializer.SetOutputWriter(sw);
            serializer.SetOutputProperty(Serializer.METHOD, "text");
            transf.Run(serializer);
            string res = sw.ToString();

After running C#, it throws exception with message:

java.lang.AssertionError: 'Saxon can't find the new component corresponding to function pA:helper#0'


Related issues

Is duplicate of Saxon - Bug #3333: Using an XSLT 3.0 package indirectly by several routesClosedMichael Kay2017-07-04

Actions
Actions #1

Updated by Michael Kay over 7 years ago

  • Description updated (diff)
Actions #2

Updated by Michael Kay over 7 years ago

  • Status changed from New to In Progress
  • Assignee set to O'Neil Delpratt

I've made this into W3C test case use-package-174; I have run it successfully from our test driver and from a Java unit test using s9api that reproduces your C# logic. We'll now try it on .NET to see if there is any difference.

Can you confirm which 9.8 maintenance release you are using?

Your application code is a bit convoluted but not actually wrong. You don't need to create three separate XsltCompilers, you can do it all from one.

Actions #3

Updated by Jiri Dolejsi over 7 years ago

From Transform.exe -versionmsg: Saxon-PE 9.8.0.3N

I tried to eliminate all possible causes of error, hence this convoluted code.

Actions #4

Updated by O'Neil Delpratt over 7 years ago

Hi,

I managed to reproduce the error you reported. Since the 9.8.0.3 maintenance release, it looks like we have fixed this problem. I am trying to investigate the bug issue with the fix.

Actions #5

Updated by O'Neil Delpratt over 7 years ago

I think this issue is a duplicate of the following bug issue: #3333.

Actions #6

Updated by O'Neil Delpratt over 7 years ago

  • Is duplicate of Bug #3333: Using an XSLT 3.0 package indirectly by several routes added
Actions #7

Updated by O'Neil Delpratt over 7 years ago

  • Status changed from In Progress to Duplicate

Please register to edit this issue

Also available in: Atom PDF