1

When i change the xsl:include to xsl:import it somehow works and doesnt return an empty file. I am using the Xslt30Processor class and function Xslt30Processor::TransformFiletoFile(), even The transform.c doesnt work. When my xslt has a "xsl:result-document" statement it also doesnt work.

I even tried using a previous version of Saxon/C (The 1.2.0 series) , and even that didnt work. Is there any option where it enables the use of xsl:include or something.

This works for Java and .NET but not for the C API. I don't get any errors or exceptions when using JNI. Please help.

Here a small example which demostrates the problem:

source.xml:

<xml/>

main.xsl:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="text" encoding="utf-8" standalone="yes"/>
  <xsl:include href="referenced.xsl" />

  <xsl:template match="/">hello</xsl:template>
</xsl:stylesheet>

referenced.xsl:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:f="my-functions.org"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                version="2.0">
  <xsl:function name="f:next-nr" as="xs:integer">
    <xsl:param name="node"/>
    <xsl:sequence select="xs:integer(replace($node, '\D', ''))"/>
  </xsl:function>
</xsl:stylesheet>

When running the C version of Transform.exe, no errors are returned and no output is produced. I noticed when putting together this test case that it doesn't matter if I change the include to import for this example. If I use the Transform.exe that comes in the tools folder of Saxon 10.6, a file is produced as expected. I can't, however, find any C/C++ files for Saxon 10.6.

The issue with result-document is a separate issue with the same outcome.

17
  • How's that related to c++?? Commented Mar 5, 2022 at 12:53
  • I'm using the C++ version of the SDK for Saxon Commented Mar 5, 2022 at 12:56
  • I don't see how xsl:include and xsl:result-document are related. Perhaps ask two different questions, for each show minimal but complete samples to allow others to reproduce the problem. Commented Mar 5, 2022 at 13:45
  • Also, if the compiled transform.c doesn't work for you, can you show us minimal samples plus the exact error message you get? Commented Mar 5, 2022 at 13:55
  • They arent related i'm just having problems with both Commented Mar 5, 2022 at 14:12

1 Answer 1

4

I think I have found one reason why the stylesheet fails on compilation, it seems a build/configuration problem with HE not finding categories.xml.

Stack trace from compilation:

Exception in thread "main" java.lang.ExceptionInInitializerError
        at net.sf.saxon.regex.RECompiler.escape(Unknown Source)
        at net.sf.saxon.regex.RECompiler.parseTerminal(Unknown Source)
        at net.sf.saxon.regex.RECompiler.piece(Unknown Source)
        at net.sf.saxon.regex.RECompiler.parseBranch(Unknown Source)
        at net.sf.saxon.regex.RECompiler.parseExpr(Unknown Source)
        at net.sf.saxon.regex.RECompiler.compile(Unknown Source)
        at net.sf.saxon.regex.ARegularExpression.<init>(Unknown Source)
        at net.sf.saxon.java.JavaPlatform.compileRegularExpression(Unknown Source)
        at net.sf.saxon.Configuration.compileRegularExpression(Unknown Source)
        at net.sf.saxon.functions.RegexFunction.tryToBindRegularExpression(Unknown Source)
        at net.sf.saxon.functions.RegexFunction.makeFunctionCall(Unknown Source)
        at net.sf.saxon.functions.Replace.makeFunctionCall(Unknown Source)
        at net.sf.saxon.functions.RegexFunctionSansFlags.makeFunctionCall(Unknown Source)
        at net.sf.saxon.functions.registry.BuiltInFunctionSet.bind(Unknown Source)
        at net.sf.saxon.functions.FunctionLibraryList.bind(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parseExpression(Unknown Source)
        at net.sf.saxon.expr.parser.XPathParser.parse(Unknown Source)
        at net.sf.saxon.expr.parser.ExpressionTool.make(Unknown Source)
        at net.sf.saxon.style.StyleElement.makeExpression(Unknown Source)
        at net.sf.saxon.style.XSLSequence.prepareAttributes(Unknown Source)
        at net.sf.saxon.style.StyleElement.<unknown>(Unknown Source)
        at net.sf.saxon.style.StyleElement.processAllAttributes(Unknown Source)
        at net.sf.saxon.style.StyleElement.processAllAttributes(Unknown Source)
        at net.sf.saxon.style.PrincipalStylesheetModule.processAllAttributes(Unknown Source)
        at net.sf.saxon.style.PrincipalStylesheetModule.preprocess(Unknown Source)
        at net.sf.saxon.style.Compilation.compilePackage(Unknown Source)
        at net.sf.saxon.style.StylesheetModule.loadStylesheet(Unknown Source)
        at net.sf.saxon.style.Compilation.compileSingletonPackage(Unknown Source)
        at net.sf.saxon.s9api.XsltCompiler.compile(Unknown Source)
        at net.sf.saxon.option.cpp.Xslt30Processor.getXslt30Transformer(Unknown Source)
        at net.sf.saxon.option.cpp.Xslt30Processor.transformToFile(Unknown Source)
Caused by: java.lang.RuntimeException: Unable to read categories.xml file
        at net.sf.saxon.regex.charclass.Categories.build(Unknown Source)
        at net.sf.saxon.regex.charclass.Categories.getCategory(Unknown Source)
        at net.sf.saxon.regex.charclass.Categories.<clinit>(Unknown Source)
        ... 47 more

So it is neither xsl:include nor xsl:result-document that causes the compilation failure, it seems the HE build does not have or does not find its categories.xml file when trying to compile the regular expression in the included code.

As a workaround, it might be possible to run SaxonC EE 11.2 without a license (-license:off), I think, as it then simply uses HE features, while somehow the EE package is correctly built to find its categories.xml so it doesn't fail on compiling regular expressions.

I have raised https://saxonica.plan.io/issues/5372 about the categories.xml file failure.

8
  • Thanks i will look into this , can you answer my comment above Commented Mar 6, 2022 at 9:53
  • Consider to raise that as a separate question with all details of what you tried and how it failed. Commented Mar 6, 2022 at 10:37
  • how did you get the java stack trace and erros when i didnt even get any errors , or a java stack trace Commented Mar 6, 2022 at 15:01
  • 1
    I've tried it out and it works with every single sheet , i didn't even need to use "-license:off" , Thanks so much Commented Mar 6, 2022 at 16:21
  • 2
    I have resolved the bug issue saxonica.plan.io/issues/5372 - patch available in the next maintenance release.
    – ond1
    Commented Mar 7, 2022 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.