xsl:result-document and Saxon-SA gives "Cannot write to a URI that has already been read"

Hi, Using oXygen 10.2, this stylesheet runs as expected with Saxon B 9.1.0.6 (the output is <foo/>) <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:template match="/"> <xsl:result-document> <foo/> </xsl:result-document> </xsl:template> </xsl:stylesheet> However if you change the transform engine to Saxon SA, it fails with: "Cannot write to a URI that has already been read: ....." cheers -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/

Hello, It was a bug in previous versions that we fixed already: the output stream of an xsl:result-document without the href atttribute is bound to the same system ID as the XML input which is already opened for reading. I cannot reproduce it with the Oxygen 10.2 build that is available on the Oxygen website. What is your Oxygen build number? Anyway it has to work for you too if you use the following Oxygen 10.3 pre-release build: http://www.oxygenxml.com/update/10.2/All/oxygen.tar.gz Version 10.3 will be released in a couple of days. Regards, Sorin Andrew Welch wrote:
Hi,
Using oXygen 10.2, this stylesheet runs as expected with Saxon B 9.1.0.6 (the output is <foo/>)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:template match="/"> <xsl:result-document> <foo/> </xsl:result-document> </xsl:template> </xsl:stylesheet>
However if you change the transform engine to Saxon SA, it fails with: "Cannot write to a URI that has already been read: ....."
cheers

It was a bug in previous versions that we fixed already: the output stream of an xsl:result-document without the href atttribute is bound to the same system ID as the XML input which is already opened for reading. I cannot reproduce it with the Oxygen 10.2 build that is available on the Oxygen website. What is your Oxygen build number? Anyway it has to work for you too if you use the following Oxygen 10.3 pre-release build:
http://www.oxygenxml.com/update/10.2/All/oxygen.tar.gz
Version 10.3 will be released in a couple of days.
Thanks, I was running 10.2, build 2009051915 after upgrading using the link you provided I'm now using 10.3, build 2009061713 ...but the problem still occurs. Running this stylesheet, using Saxon SA 9.1.0.6 in oXygen (10.2 or 10.3 :) gives: "Cannot write to a URI that has already been read: ..." <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:template match="/"> <xsl:result-document> <foo/> </xsl:result-document> </xsl:template> </xsl:stylesheet> cheeeers -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/

I get the same error as you *only* when the output file is set to be the same as the input XML file but: - I get the error with both Saxon B and Saxon SA, - it is an error reported correctly (not the bug that I mentioned) and - I get the same behavior in Oxygen as from a command line where I run Saxon B/SA. You get the error only with Saxon SA so there is something different in your transformation scenario. Please specify more details about your scenario: the URL of the input XML, the URL of the input XSL, the value of the field Save As, the full error message (including the URI that cannot be written). Thank you, Sorin Andrew Welch wrote:
Running this stylesheet, using Saxon SA 9.1.0.6 in oXygen (10.2 or 10.3 :) gives: "Cannot write to a URI that has already been read: ..."
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:template match="/"> <xsl:result-document> <foo/> </xsl:result-document> </xsl:template> </xsl:stylesheet>
cheeeers

Hi, 2009/6/25 Sorin Ristache <sorin@oxygenxml.com>:
I get the same error as you *only* when the output file is set to be the same as the input XML file but:
- I get the error with both Saxon B and Saxon SA,
- it is an error reported correctly (not the bug that I mentioned) and
- I get the same behavior in Oxygen as from a command line where I run Saxon B/SA.
You get the error only with Saxon SA so there is something different in your transformation scenario. Please specify more details about your scenario: the URL of the input XML, the URL of the input XSL, the value of the field Save As, the full error message (including the URI that cannot be written).
Its writing to standard out... I'm not setting any output file. Its works as expected for me from the command line, and from Kernow, but not from oXygen. To recreate the problem in oXygen: - file -> new -> xsl - paste in the xslt - configure transformation scenario -> new -> choose Saxon SA - set XML and XSL to ${currentFileURL} - click ok, the click run transform Do that and you get the exception. You are probably resolving the href of xsl:result-document against the uri of the stylesheet, and because there is no href, the uri of the stylesheet is returned. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/

Hi Andrew, When you specify as XML input ${currentFileURL} for the transformation that will be resolved to the stylesheet location, as that is the current file when you run the transformation. If there is no output specified oXygen sets on the output stream a system ID (to have eventual references to images for instance resolved correctly in the XHTML preview) and uses the stylesheet location for that. But as the stylesheet is set also as input Saxon complains that it cannot write to that location. We get however the same behavior for both Saxon B and Saxon SA in oXygen. If you do not need an input for the transformation then use the advanced processor options in the scenario to set initial template/initial mode for the transformation. Best Regards, George -- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com Andrew Welch wrote:
Hi,
2009/6/25 Sorin Ristache <sorin@oxygenxml.com>:
I get the same error as you *only* when the output file is set to be the same as the input XML file but:
- I get the error with both Saxon B and Saxon SA,
- it is an error reported correctly (not the bug that I mentioned) and
- I get the same behavior in Oxygen as from a command line where I run Saxon B/SA.
You get the error only with Saxon SA so there is something different in your transformation scenario. Please specify more details about your scenario: the URL of the input XML, the URL of the input XSL, the value of the field Save As, the full error message (including the URI that cannot be written).
Its writing to standard out... I'm not setting any output file.
Its works as expected for me from the command line, and from Kernow, but not from oXygen.
To recreate the problem in oXygen:
- file -> new -> xsl - paste in the xslt - configure transformation scenario -> new -> choose Saxon SA - set XML and XSL to ${currentFileURL} - click ok, the click run transform
Do that and you get the exception.
You are probably resolving the href of xsl:result-document against the uri of the stylesheet, and because there is no href, the uri of the stylesheet is returned.

Hi George,
When you specify as XML input ${currentFileURL} for the transformation that will be resolved to the stylesheet location, as that is the current file when you run the transformation.
If there is no output specified oXygen sets on the output stream a system ID (to have eventual references to images for instance resolved correctly in the XHTML preview) and uses the stylesheet location for that. But as the stylesheet is set also as input Saxon complains that it cannot write to that location.
Thanks for the explanation
We get however the same behavior for both Saxon B and Saxon SA in oXygen.
Yeah me too now, my Saxon B scenario had a different xml file set... sorry about that.
If you do not need an input for the transformation then use the advanced processor options in the scenario to set initial template/initial mode for the transformation.
Ahh ok cool, I didn't notice that.... thanks. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
participants (3)
-
Andrew Welch
-
George Cristian Bina
-
Sorin Ristache