Project

Profile

Help

Exception Using the sql extension

Added by Nic Gibson over 7 years ago

We're getting a strange problem when we are using the sql extension. In general, it works fine but we are seeing a problem with the following:

We have a query which should return something like -


  
  
  
  53
  533
  244
  Archaeology
  Prehistory
  Ancient history
  A1
  350

The code is wrapped up in functions -


  
    
    
    
    
        
        
    
    
  

  
    
    
    
    
    
    
    
      
    
       
    
    
  

Running from a terminal (MacOS or Linux) gives

nicg$ saxon  -xsl:db-test.xsl -it:main -o:db-results-02.xml -config:conf/saxon-cfg_basic.xml 
java.lang.UnsupportedOperationException: SimpleExpression.copy()
	at net.sf.saxon.expr.SimpleExpression.copy(SimpleExpression.java:114)
	at net.sf.saxon.expr.ItemChecker.copy(ItemChecker.java:248)
	at net.sf.saxon.expr.SlashExpression.copy(SlashExpression.java:609)
	at net.sf.saxon.expr.sort.DocumentSorter.copy(DocumentSorter.java:138)
	at com.saxonica.ee.optim.OptimizerEE.tryInlineFunctionCall(OptimizerEE.java:1022)
	at net.sf.saxon.expr.UserFunctionCall.optimize(UserFunctionCall.java:343)
	at net.sf.saxon.expr.parser.ExpressionVisitor.optimize(ExpressionVisitor.java:246)
	at net.sf.saxon.expr.instruct.ParentNodeConstructor.optimize(ParentNodeConstructor.java:208)
	at net.sf.saxon.expr.instruct.ElementCreator.optimize(ElementCreator.java:92)
	at net.sf.saxon.expr.instruct.FixedElement.optimize(FixedElement.java:103)
	at net.sf.saxon.style.XSLFunction.optimize(XSLFunction.java:448)
	at net.sf.saxon.style.StylesheetPackage.compile(StylesheetPackage.java:1092)
	at net.sf.saxon.style.Compilation.compilePackage(Compilation.java:201)
	at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:94)
	at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:543)
	at net.sf.saxon.Transform.doTransform(Transform.java:601)
	at net.sf.saxon.Transform.main(Transform.java:80)
Fatal error during transformation: java.lang.UnsupportedOperationException: SimpleExpression.copy()

Other functions called at the same time succeed. I've attached a slightly more complete version of the stylesheet including one of the working functions. If we comment out the call to cup:isbn-subject-query we get the expected results. If we comment out everything else it fails. I've also attached the simple driver we are using for testing.

If the function call to cup:book-meta() is replaced with a call to cup:isbn-subject-query in the driver, the code runs exactly as expected.

Any suggestions?

cheers

nic


Replies (4)

Please register to reply

RE: Exception Using the sql extension - Added by Michael Kay over 7 years ago

Thanks for reporting it: noted as an issue here

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

(Every expression kind is represented by a class of Java object that extends Expression. These classes are required to supply a copy() method so that an expression can always be copied, for example if a function is inlined. The error means that one of the SQL expression classes has not implemented this method. This will not manifest as a problem unless the optimizer tries to copy the expression, for example in the course of function inlining.)

RE: Exception Using the sql extension - Added by Michael Kay over 7 years ago

The line numbers suggest that this is Saxon 9.6 (or perhaps earlier). The problem appears to have been fixed in Saxon 9.7. Please always tell us which Saxon version you are using when reporting a problem.

We're very unlikely to produce a fix for Saxon 9.6 at this stage in its life. We would only do so for a paying customer who has a good reason for not moving forward, and then only if we can't identity any workaround. You can probably work around the problem by doing something that prevents the function being inlined, for example by making it appear to be recursive.

RE: Exception Using the sql extension - Added by Nic Gibson over 7 years ago

Apologies - I meant to mention that this was 9.6. There are small issues related to CUP wanting to use the same version of Saxon as is currently used in Oxygen but I'm going to move this particular tool over to 9.7 and see if the problem is resolved.

RE: Exception Using the sql extension - Added by Nic Gibson over 7 years ago

I can confirm that the problem doesn't occur using Saxon 9.7

    (1-4/4)

    Please register to reply