Hi there,

 

Thanks for the quick answer.

 

As you might of guessed I was trying to not have to go through literally 1,000’s of lines of code and have the XSLT work in 9.x as it did in 6.x. I can understand things need to move on and if we have to spend time finding out where the issue is to use xsl:result-document so be it.

 

Thanks again for your comments and pointers.

 

Russell.

 

From: Michael Kay [mailto:mike@saxonica.com]
Sent: 13 December 2011 10:28
To: saxon-help@lists.sourceforge.net; russellbeaton@gmail.com
Subject: Re: [saxon] Ouput redirection in Saxon 9.x

 


When functionality equivalent to Saxon extensions has been incorporated into the base XSLT standards, I've generally dropped the extension, usually after an overlap period of two or three releases when both were available. This doesn't help, of course, when people try to move forward by about 30 releases in one jump. So saxon:output was dropped a long time ago, in favour of xsl:result-document. However, xsl:result-document doesn't do exactly the same thing; in particular the rules were defined more restrictively to prevent the effect of your stylesheet depending (deliberately or unwittingly) on the order of instruction execution. This is why you get the error "Cannot switch to a final result destination while writing a temporary tree".

The xsl:document instruction, in the form you are using it, was defined in the XSLT 1.1 Working Draft, which existing for a few months around 2000 before being withdrawn. It is now history. The name xsl:document was reused in XSLT 2.0 for an instruction that does something rather different. I've no idea about exsl:document - I don't think it's ever been implemented in Saxon.

xsl:result-document is the way to go, but to see why you are getting the error, we would need to see where the containing template is being called from.

Michael Kay
Saxonica


On 12/12/2011 10:44, Russell Beaton wrote:

Hi There,

 

I have recently taken over a rather old and large Chunker XLST written for Saxon 6.5.2 that is part of a big development. The parser that runs the XLST this now has been upgraded to Saxon 9.1.0.5. As you can imagine, we neither have to time or resources to redevelop/migrate this XSLT  from 6.5.2 to 9.1.0.5.

 

The Chunker works perfectly and has been working perfectly for years under 6.5.2, so the simplest and most direct route to execute in 9.x would be great.

 

The assumption is that a majority, if not all the code should be compatible with 9.x. as far as I can tell it is with a bit of tweaking except for last issue of output redirection to the file system (there is always an except…). The XSLT currently uses <saxon:output> for 6.x.  The code snippet below shows my various attempts at redirecting HTML output to the file system. As you can see I get various errors using different output functions.

 

So my question is, shouldn’t <saxon:output> or <xsl:document> work out of the box in version 9.x? As I am a novice comparatively, it would be great if someone could let me know the error of my ways.

 

Please see the Chunker code output snippet below with the various error messages in the comment just about the output call. As you can imagine there are many variations of attributes I have tried for different scenarios e.g. version=1.0, 2.0, 1.1 etc as well various ‘method’, ‘encoding’ etc.

 

Thanks in anticipation,

 

Russell.

 

 

 

 

=======  Chunker.xsl ========

 

<xsl:stylesheet version="1.0"

  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  xmlns:saxon="http://icl.com/saxon"

  xmlns:exsl="http://exslt.org/common"

  xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"

  extension-element-prefixes="saxon exsl">

 

  <xsl:param name="default.encoding" select="'ISO-8859-1'" doc:type='string'/>

  <xsl:param name="saxon.character.representation" select="'entity;decimal'" doc:type='string'/>

 

  <doc:param name="saxon.character.representation" xmlns="">

    <refpurpose>Saxon character representation used in generated HTML pages</refpurpose>

    <refdescription>

      <para>This character representation is used in files generated by chunking stylesheet. If

        you want to suppress entity references for characters with direct representation

        in default.encoding, set this parameter to value <literal>native</literal>.

      </para>

    </refdescription>

  </doc:param>

 

  <xsl:output method="html" encoding="ISO-8859-1" indent="no"/>

 

<xsl:template name="write.chunk">

  <xsl:param name="filename" select="''"/>

  <xsl:param name="method" select="'html'"/>

  <xsl:param name="indent" select="'yes'"/>

  <xsl:param name="content" select="''"/>

    

<!--  <xsl:variable name="filenameVar"

    select="concat('file:///C:/temp/','', $filename)" /> -->

 

<!--  <xsl:variable name="filenameVar"

    select="concat('C:/temp/','', $filename)" /> --> 

 

 

<!--

Description: Unknown extension instruction

-->

<!--

<saxon:output href="file:///C:/Temp/{$filename}"

method="{$method}"

encoding="{default.encoding}"

indent="{$indent}">

<xsl:copy-of select="$content"/>

</saxon:output>

-->

 

  

<!--

Description: Cannot switch to a final result destination while writing a temporary tree

-->

<!--<xsl:result-document href="{$filename}">

<xsl:copy-of select="$content"/>

</xsl:result-document>-->

 

 

<!--

Description: Attribute @href is not allowed on element <xsl:document>

-->  

<!--<xsl:document href="{$filename}"

method="{$method}"

encoding="{default.encoding}"

indent="{$indent}">

<xsl:copy-of select="$content"/>

</xsl:document>-->

 

  

<!--

Description: Unknown extension instruction

-->

<exsl:document href="file:///C:/Temp/{$filename}">

<xsl:copy-of select="$content"/>

</exsl:document>

 

</xsl:template>

 

</xsl:stylesheet>




------------------------------------------------------------------------------
Systems Optimization Self Assessment
Improve efficiency and utilization of IT resources. Drive out cost and 
improve service delivery. Take 5 minutes to use this Systems Optimization 
Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/




_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help