Hi Michael,

 

Well I must say a big thanks to you for looking so quickly into this. I appreciate your patience in doing so and understand that this forum is not a ‘freebee’ service.  Being a novice, I was just trying to get an understanding to see if I was not doing something rudimentary ‘silly’ in the way to go about debugging these XSLTs.

 

Once again, thanks for your help so far and I will persist in finding the issue(s).

 

Cheers,

 

Russell.

 

From: Michael Kay [mailto:mike@saxonica.com]
Sent: 15 December 2011 12:57
To: Russell Beaton
Cc: saxon-help@lists.sourceforge.net
Subject: Re: [saxon] Ouput redirection in Saxon 9.x

 

Warning to anyone who tries running this: the stylesheet writes to your c:/temp directory (or fails to, if you're not on Windows).

I can't see why you're getting this error either, though I can reproduce it under 9.3.

I get a different error under 9.4:

Error at xsl:result-document on line 80 of chunker.xsl:
  XTDE1490: Cannot write more than one result document to the same URI:
  file:/Users/mike/bugs/2011/beaton/XSL/out/part01.html

Since the filename is a parameter to write.chunk, and there are 93 different calls to write.chunk, it's going to take some patient debugging to get to the bottom of that.

Running with -t gives this:

Writing ch1.1.2.3.2.3.5sect2.html-----(Saxonica)----- for section(mspm_ptb_ch1_4)
Writing to file:/Users/mike/bugs/2011/beaton/XSL/out/out/ch1.1.2.3.2.3.5sect2.html
Writing ch1.1.2.3.2.3.html-----(Saxonica)----- for chapter(mspm_ptb_ch1)
Writing to file:/Users/mike/bugs/2011/beaton/XSL/out/out/ch1.1.2.3.2.3.html
Writing part01.html-----(Saxonica)----- for part(mspm_ptb)
Writing to file:/Users/mike/bugs/2011/beaton/XSL/out/out/part01.html
Writing part01.html-----(Saxonica)----- for part(mspm_ptb)
Error at xsl:result-document on line 80 of chunker.xsl:
  XTDE1490: Cannot write more than one result document to the same URI:
  file:/Users/mike/bugs/2011/beaton/XSL/out/out/part01.html
Transformation failed: Run-time errors were reported

Running with -T gives a vast amount of trace, but shows that both the calls of write.chunk are from the match="book/part" template on line 4853 of collection.xsl. This template has a rather strange structure where it constructs a variable called $content containing an HTML page, it then writes this out to a filename $filename, then constructs another variable called $contents, and a variable called $filenames which is the same as the first $filename; but instead of writing $contents to $filenames, it repeats the write of $content to $filename.

Writing two documents to the same URL is clearly wrong (the one you end up with depends on order of execution), so you are falling foul of the fact that Saxon 9.x is detecting errors that Saxon 6.x failed to detect.

I removed this error and tried again; it got a little bit further and failed with:

Error at xsl:result-document on line 80 of chunker.xsl:
  XTDE1490: Cannot write more than one result document to the same URI:
  file:/Users/mike/bugs/2011/beaton/XSL/out/out/l11.1.2.2.2.html

I'm afraid this isn't a free programming or debugging service. We can try and help you understand what the error messages mean, but we can't write your code for you. Apart from anything else, I think it will sooner or later need an understanding of what the code is actually trying to do. If you need expert assistance and have a budget to pay for it, then I can try and help you find someone.

Regards,

Michael Kay
Saxonica


On 15/12/2011 11:10, Russell Beaton wrote:

Hi Everyone,

 

I have attached a group of XLST’s which were ‘bequeathed’ to me and written in Saxon 6.x. Also, the way they went about creating the XSLTs even from my novice perspective is something to be said. The parser (which I cannot change) has been upgraded to 9.x.

 

The XSLTs works  as expected in 9.x except for < xsl:result-document > which appears to give me an error of "Cannot switch to a final result destination while writing a temporary tree”.

 

I cannot, being a novice, find what is causing the issue as it is very complicated for me at this stage. I have searched for the above message and have ideas of course, but to no avail.

 

I have attached the associated XLSTs if anyone would like a cursory glance to possibly help out?

 

To execute: Use the “collection.xsl” on the data file ”TestData.xml”

 

Thanks in advance,

 

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