Project

Profile

Help

Optimizer rewrites expression so that stylesheet is not streamable

Added by Martin Honnen over 6 years ago

When I run the stylesheet




	
	
	
	
	
	
	
	
		
		

								
	
	
	
		
		

	
	


with @Saxon-EE 9.8.0.4J@ from the command line it compiles the stylesheet fine, starts to run it with streaming as it indicates with e.g.

Processing file:/C:/SomePath/test2017100201.xml
Streaming file:/C:/SomePath/test2017100201.xml

and then aborts processing with the error

Error on line 20 of test201710020106.xsl:
  XTSE3430: Template rule is not streamable
  * Operand {@attribute()} of {let $vv:v0 := ...} selects streamed nodes in a context that
  allows arbitrary navigation (line 21)
Template rule is not streamable
  * Operand {@attribute()} of {let $vv:v0 := ...} selects streamed nodes in a context that allows arbitrary navigation (
line 21)

As that cited expression doesn't seem to exist in the stylesheet I tried to run with @-opt:0@ to disable the optimizer and then the stylesheet runs through fine with streaming.

Is there any way other than with @-opt:0@ to prevent Saxon from rewriting the @xsl:value-of@ to be no longer streamable?

A sample input is




	
		
		
		
		
	
	
		
		
		
	


Replies (1)

RE: Optimizer rewrites expression so that stylesheet is not streamable - Added by Michael Kay over 6 years ago

I can repeat this failure..

It's useful in such cases to run with -explain, which shows the main rewrites done by the optimizer:

OPT : At line 12 of file:/Users/mike/Desktop/temp/test.xsl OPT : Pre-evaluated function call fn:tokenize(...) OPT : Expression after rewrite: ("id", "dummyAttr1", "dummyAttr2", "dummyAttr3", "dummyAttr4") OPT : At line 21 of file:/Users/mike/Desktop/temp/test.xsl OPT : Lifted (@attribute()) above ((xsl:value-of, ...)) on line 21 OPT : Expression after rewrite: let $Q{http://saxon.sf.net/generated-variable}v0 := attribute::attribute() return (Block(ValueOf(string-join(for $col in $columns return (concat(atomizeSingleton($Q{http://saxon.sf.net/generated-variable}v0[(name(.)) eq $col]), "")), ",")), ValueOf(" ")))

The problem is that the rewritten code binds a variable to a streamed node, which isn't allowed. Armed with this knowledge, you can work around the problem by suppressing loop-lifting optimizations with -opt:-l

Clearly rewriting streamable code to non-streamable form is against the rules so I'll have to find some way to prevent this.

Raised and resolved here: https://saxonica.plan.io/issues/3465

    (1-1/1)

    Please register to reply