2

Just what it says on the tin.

I'm new to XSLT 3.0. I'm excited to try it out because so much of my work involves relatively simple operations on huge XML files.

I'm discovering that there are several requisites for XML to ACTUALLY stream, but I'm both unclear on what they are, and not terribly confident in my ability to write XSLT (the compiler is my favorite debugging tool).

How can I tell if the XSLT I've written is actually streaming XML, versus working correctly but in a non-streaming fashion?

Matt
  • 775
  • 7
  • 24

1 Answers1

3

If you request streaming (with e.g. <xsl:mode streamable="yes"/>) and use Saxon 9.8 or 9.9 EE (so far the only implementations to support that part of XSLT 3) then it will do a streamability analysis of your code during stylesheet compilation and inform you whether you have used any constructs it doesn't consider streamable.

At least that is the case if you run Saxon from the command line. Inside oXygen I think you explicitly need to request in the Saxon EE specific transformation scenario settings that you want to use streaming (see https://www.oxygenxml.com/doc/versions/21.1/ug-editor/topics/advanced-saxon-xslt-options-x-publishing2.html?hl=streaming and the "Enable streaming mode" option).

As with most Saxon configurations, there is also the option to use a configuration file http://saxonica.com/html/documentation/configuration/configuration-file/.

If you request streaming in your code and run Saxon EE from the command line then it will not execute the code if it doesn't consider it streamable.

That is a rough overview, for details see http://saxonica.com/html/documentation/sourcedocs/streaming/.

In addition, once you get by the streamability analysis, you can use the -t option on the command line, it will show which parser is used for which input document and whether a tree is built or it is processed with streaming.

In my experience you kind of need to relearn how to use XSLT if you want to use streaming, many techniques you might be used to (xsl:call-template, storing nodes in variables) might not work if you are dealing with pure streaming. There is often a way to mix streaming with traditional tree based processing by using copy-of() and/or snapshot(). There are also new features like accumulators that help make your code streamable, for instance if you use them instead of xsl:number or instead of keys.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • This is good information, thanks. Unfortunately, I'm using Notepad++ instead of Oxygen, and the IDE that's using my XSLT doesn't seem to expose the command line options for their Saxon interpreter. It's kind of a convoluted setup... It's good to know that I should expect to see some kind of response about whether or not it's streamable. I'll bet I can find it in the runtime logs, if I dig around enough. – Matt Feb 05 '20 at 18:57