Project

Profile

Help

Support #3539

closed

Template rule is not streamable

Added by abhishek munjal over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Streaming
Sprint/Milestone:
-
Start date:
2017-11-21
Due date:
% Done:

0%

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

Description

I Have a input XML hierarchy like this:

Here Sender and Summary occurs once and Persons is a repeating node. I want to produce similar output XML (by applying some xslt rules).

For-each is applied on Persons node : <xsl:for-each select="LendingDataMessage/Persons ! copy-of(.)">

Every time i run the XSLT in streaming mode , it gives me error : Template rule is not streamable * There is more than one consuming operand.

If i remove Sender and Summary nodes then it works fine . Could you please help me out how to achieve the correct output.

Sample XSL and input XML is attached.


Files

sample.xsl (2.45 KB) sample.xsl abhishek munjal, 2017-11-21 13:01
MockSource2.xml (75.8 KB) MockSource2.xml abhishek munjal, 2017-11-21 13:02
sample2.xsl (2.42 KB) sample2.xsl Michael Kay, 2017-11-21 13:32
Actions #1

Updated by Michael Kay over 6 years ago

I attach sample2.xsl which shows how your code can be made streamable by splitting it into template rules.

The reason this works is fairly subtle. In your code, the sequential logic means that Sender, Summary, and Persons are always produced in that order, regardless what order they appear in the input. The XSLT compiler doesn't know what order they appear in the input, so it has to assume the worst, which means that the output order might not be the same as the input order, and that makes the code non-streamable. By rewriting it using template rules, my revised version outputs Sender, Summary, and Persons in whatever order they appear in the input (they might always be in that order, but the code will still work if they aren't). So the code isn't doing any re-ordering, and is therefore streamable.

Actions #2

Updated by Michael Kay over 6 years ago

  • Tracker changed from Bug to Support
  • Status changed from New to In Progress
Actions #3

Updated by abhishek munjal over 6 years ago

Thank you Michael!!

Actions #4

Updated by Michael Kay over 6 years ago

  • Category set to Streaming
  • Status changed from In Progress to Closed
  • Assignee set to Michael Kay

Please register to edit this issue

Also available in: Atom PDF