Project

Profile

Help

Bug #1632

closed

Streaming

Added by Jakub Maly over 11 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Streaming
Sprint/Milestone:
-
Start date:
2012-10-04
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

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

errorlog.txt (2.27 KB) errorlog.txt Jakub Maly, 2012-10-04 23:03
split.xsl (2.88 KB) split.xsl Jakub Maly, 2012-10-04 23:03
zastupci.xml (1.31 KB) zastupci.xml Jakub Maly, 2012-10-05 00:29
split.xsl (3.42 KB) split.xsl Jakub Maly, 2012-10-05 00:55
Actions #1

Updated by Michael Kay over 11 years ago

  • Status changed from New to In Progress
  • Assignee set to Michael Kay
Actions #2

Updated by Michael Kay over 11 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.

Actions #3

Updated by Jakub Maly over 11 years ago

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".

Actions #4

Updated by Jakub Maly over 11 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).

Actions #5

Updated by Jakub Maly over 11 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

Actions #6

Updated by Michael Kay over 11 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.

Actions #7

Updated by Michael Kay over 11 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.

Actions #8

Updated by Jakub Maly over 11 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.

Actions #9

Updated by Michael Kay over 11 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.

Actions #10

Updated by Michael Kay over 11 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.

Actions #11

Updated by Michael Kay about 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

Also available in: Atom PDF