Bug #1632
closedStreaming
100%
Description
Running the stylesheet attached, I end up with an exception:
java.lang.ClassCastException: net.sf.saxon.expr.instruct.Template cannot be cast to com.saxonica.stream.TemplateInversion
(the full stack trace is attached).
Files
Updated by Michael Kay about 12 years ago
- Status changed from New to In Progress
- Assignee set to Michael Kay
Updated by Michael Kay about 12 years ago
Since this is a run-time error, it would be very useful to have a source document that allows me to reproduce the problem. A small one, ideally!
I think it may be related to the mode=#all template. A streaming apply-templates instruction has selected for processing a template rule that has not been prepared for streaming, and this could be because the mode="#all" rule is causing confusion as to whether it is part of the streamable mode or not.
Updated by Jakub Maly about 12 years ago
- File zastupci.xml zastupci.xml added
Here is the document I open using doc function
(through
<xsl:call-template name="process-ruian-file">
<xsl:with-param name="uri" select="xs:anyURI('vzorky/input.xml')"/>
</xsl:call-template>
).
The initial mode is "s" and initial template "main".
Updated by Jakub Maly about 12 years ago
I still can not get this to work and would be greatful for any help.
I am attaching a slightly modified version of the stylesheet.
It works with streamable="no" but fails with streamable="yes" -- either I ran into the exception above or I get a different result than with streamable="no" (when the stylesheet finishes, the result document looks like it has been transformed by the implicit stylesheet rules only (as if no mode is applied).
Updated by Jakub Maly about 12 years ago
I am running it using the following command:
java net.sf.saxon.Transform -xsl:split.xsl -o:output.xml -it:main -im:s
Updated by Michael Kay about 12 years ago
The primary problem is the [position() < 3] predicate. Saxon can't currently hande positional predicates when streaming (it doesn't count the nodes and remember how many there have been). I've been doing work in this area in 9.5, but it still can't handle this case - though I shall work on it.
The secondary problem is the absence of diagnostics as to the cause. I'll see if I can fix that in a 9.4 patch.
I think your best bet to implement a streaming solution for this one is probably to use xsl:iterate - this allows you to maintain your own count of how many vf:Data/* elements you have seen, and to do different processing based on the value.
Updated by Michael Kay about 12 years ago
Incidentally, the option -explain:on is often useful with streaming. In this case (before crashing) it outputs the message
Cannot use streaming apply-templates: Cannot convert the expression {subsequence(child::element(), 1, 2)} to a pattern
Which might not be completely user-friendly, but gives a hint as to where the problem lies.
Updated by Jakub Maly about 12 years ago
Thanks, I will get back to the stylesheet later today. I don't need the position test at all - I put it there just to get a smaller result for debugging.
Updated by Michael Kay about 12 years ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
- Fixed in version set to 9.4.0.6
A patch was included in 9.4.0.6 to improve the diagnostics on this (it explains that the code is not streamable).
Version 9.5 will be able to handle (some) positional selections in streaming mode, so this has provided a useful test case.
Updated by Michael Kay about 12 years ago
- Status changed from Closed to In Progress
Unfortunately this patch was incorrect and it throws an error in the case of apply-templates calls that are genuinely streamable. I am therefore reverting the patch.
Updated by Michael Kay over 10 years ago
- Status changed from In Progress to Closed
Closed as unresolved. Streaming advanced significantly in 9.5 and will advance even more significantly in 9.6; there's no plan to improve the number of cases that can be handled in 9.4 and no particular motivation to pursue this particular test case.
Please register to edit this issue