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.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • How's that related to c++?? – πάντα ῥεῖ Mar 05 '22 at 12:53
  • I'm using the C++ version of the SDK for Saxon – ibrahim muhmud usmani Mar 05 '22 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. – Martin Honnen Mar 05 '22 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? – Martin Honnen Mar 05 '22 at 13:55
  • They arent related i'm just having problems with both – ibrahim muhmud usmani Mar 05 '22 at 14:12
  • Please try to narrow down the problem and be more specific. Take one specific sequence of events that doesn't produce the expected results, tell us exactly what you are doing, and exactly how it failed. Think about all the information that will be needed by someone trying to reproduce the effect you are seeing. – Michael Kay Mar 05 '22 at 14:14
  • I dont get any error message – ibrahim muhmud usmani Mar 05 '22 at 14:14
  • If `xsl:import` works and `xsl:include` doesn't, then by far the most likely explanation is that it's an error in your XSLT code. – Michael Kay Mar 05 '22 at 15:01
  • Getting `xsl:result-document` to show up where you expect it might depend on setting `setBaseOutputURI` before. – Martin Honnen Mar 05 '22 at 16:01
  • Thanks for the suggestion about `setBaseOutputURI`, I'll give that a try. I've updated the question with a small independent example. – ibrahim muhmud usmani Mar 05 '22 at 18:55
  • Hm, you are right, somehow SaxonC HE 11.2 fails to output anything with your example. Let's see when/how someone from Saxonica picks that up as a bug. – Martin Honnen Mar 05 '22 at 19:06
  • To give you can example that works for me with SaxonC HE 11.2's `Transform.exe` from the command line, https://github.com/martin-honnen/martin-honnen.github.io/blob/master/xml/2022/sheet4.xsl includes https://github.com/martin-honnen/martin-honnen.github.io/blob/master/xml/2022/sheet1.xsl and runs fine against e.g. https://github.com/martin-honnen/martin-honnen.github.io/blob/master/xml/2022/sample1.xml, producing a primary result and three additional result documents. Not much of a help after your initial and simple attempt failed but let's see what Saxonica has to say on that, I don't know. – Martin Honnen Mar 05 '22 at 19:16
  • Somehow SaxonC seems to fail when trying to compile the stylesheet. Still not sure what causes the failure. – Martin Honnen Mar 05 '22 at 19:39
  • The code is compiled and executed fine with SaxonC EE 11.2. Still not sure why SaxonC HE 11.2 fails. – Martin Honnen Mar 05 '22 at 20:11
  • Hi, I noticed you mentioned the use of `Xslt30Processor::TransformFiletoFile()`. Is it possible you can share your C++ code please. – ond1 Mar 05 '22 at 20:15
  • Also I get "JET RUNTIME ERRORs" that return an exit code of 9 – ibrahim muhmud usmani Mar 06 '22 at 06:46
  • The JET RUNTIME might be related to the "Unable to read categories.xml file" issue. Please can you detail the steps you followed for you to get this error or at least the command you ran. – ond1 Mar 06 '22 at 11:04

1 Answers1

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.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • Thanks i will look into this , can you answer my comment above – ibrahim muhmud usmani Mar 06 '22 at 09:53
  • Consider to raise that as a separate question with all details of what you tried and how it failed. – Martin Honnen Mar 06 '22 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 – ibrahim muhmud usmani Mar 06 '22 at 15:01
  • how do I use Saxon EE without a license ??? – ibrahim muhmud usmani Mar 06 '22 at 15:03
  • I wrote C++ code using , similar to the samples in `samples/cppTests/testXSLT30.cpp`, using `transformFileToFile` with your XML and XSLT samples. Checked `xslt30_processor->exceptionOccurred()` and output `getErrorMessage()`. I am not sure at the moment and not at the computer where I did the test to check, it might be that the long stack trace is only output because I used in a setup after uncommenting the `DEBUG` flag in SaxonProcessor.h. – Martin Honnen Mar 06 '22 at 15:08
  • I would try to download and install SaxonC EE the same way you downloaded and installed HE, then try to compile the `command/transform.c`, if that succeeds, try to execute it (i.e. `transform.exe` on Windows or `transform` on Linux) (after setting `SAXONC_HOME`), if it gives an error about a missing license, try running it with the command line flag `-license:off`, I think it should run then without needing the license. I am sure Saxonica will give you an evaluation license at https://www.saxonica.com/download/download.xml, if the `license:off` workaround doesn't work. – Martin Honnen Mar 06 '22 at 15:13
  • 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 – ibrahim muhmud usmani Mar 06 '22 at 16:21
  • 2
    I have resolved the bug issue https://saxonica.plan.io/issues/5372 - patch available in the next maintenance release. – ond1 Mar 07 '22 at 12:47