Without seeing your code, it's impossible to be specific about what's going wrong here. There would basically seem to be two possibilities:

(a) you are hitting one of the small number of incompatibilities introduced by the XSLT 2.0 specification. These are listed here:


For example, it could be that your stylesheet fails because of the new rules that make whitespace stripping of the source document sensitive to the definitions in the DTD. Note that if you want maximum backwards compatiblity, you should leave the version attribute set to version="1.0".

(b) (more likely) it's possible that the stylesheet depends on Saxon extensions or implementation-defined features (that is, areas where the behavior can vary from one XSLT implementation to another) that have changed in the course of time as the Saxon product evolves. Each major Saxon release introduces a few small changes and when you skip forward 23 major releases in one go, as you have done, the cumulative effect can be quite substantial.

The message "cannot switch to a final result destination" suggests you are using xsl:result-document, which is an XSLT 2.0 feature that wasn't available in XSLT 1.0. Perhaps you were using the equivalent Saxon extension in Saxon 6.5 (the saxon:output instruction), which offered similar functionality but not in a 100% compatible way?

>As there are many lines of XSLT code, are there any specific lines that I can need to look out for to help me fix this?

I'd suggest comparing the trace output you get from the -T option in both releases. Of course there are many changes in the actual format of the trace, but you should be able to see at what point there is a structural change, and this might give a clue. On the other hand, there could be structural changes in the sequence of execution caused by new optimizations that have been introduced over the years. The best approach might be to reduce the problem to its essentials by cutting out irrelevant detail from the stylesheets, and then post it here for someone else to look at.

Michael Kay

On 02/12/2011 11:40, Russell Beaton wrote:



Ok, I am a sort of XSLT newbie, so please bear with me. I am attempting to parse with 1.0, 1.1 XSLT in Saxon 9.x i.e.2.0.


My initial thought is that version 1.0 XSLT should be inherently compatible with a version 2.0 parser but a series of small tests proves otherwise.


Using Oxygen V12,  I ran tests using Saxon 6.x and this worked as expected. The Saxon 6.x parser traversed all siblings and children nodes. Switching the parser to Saxon 9.x appears to only parse the top level. In this the case ‘Document/Topic’ template. It does not traverse using any other siblings or child level templates.


By putting an ‘<xsl:apply-templates/>’ at the end of the ‘Document/Topic’ template,  I can force the Saxon 9.x parser to find the next child i.e. ‘Document/Topic/Topic’ template. But then it stops again. Lastly, if I put another ‘<xsl:apply-templates/>’ at the end of the ‘Document/Topic/Topic’ template, I get a Saxon error message of “…\XSL\chunker.xsl Engine name: Saxon-PE Severity: fatal Description: Cannot switch to a final result destination while writing a temporary tree”.


So as you might imagine this leads me to think that there is a difference in the way the error/validation/parser checking is done between version 1.x and 2.x parsers. Yes I have read various similar threads be to no avail.


As there are many lines of XSLT code, are there any specific lines that I can need to look out for to help me fix this?


Thanks in anticipation,