Actions
Bug #3367
closedfunction not found inside xslt package
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
Please register to edit this issue
Actions