xsl:result-document with no href causes "Cannot write to a URI that has already been read" err-XTRE1500

Hi, Congratulations on integrating Saxon-SA - a great move! I think there is a slight issue, this stylesheet (when run against itself with no output file given) causes the exception "Cannot write to a URI that has already been read": <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:template match="/"> <xsl:result-document validation="strict"> <foo/> </xsl:result-document> </xsl:template> </xsl:stylesheet> Also, in the "Saxon SA" specific options, -val and -vlax should be radio buttons shouldn't they (with a third option for skip)? I personally would like like the default to be -vlax rather than -val, otherwise you are forced to disable it if you want to use Saxon SA but aren't using input validation. One last thing, an inbuilt "xslt 2.0" file/new template would be great, with: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"> thanks -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/

Andrew Welch wrote:
Congratulations on integrating Saxon-SA - a great move!
Definitively! And that should benefit both sides. I hope that will boost SA developments by getting more developers used to it.
I think there is a slight issue, this stylesheet (when run against itself with no output file given) causes the exception "Cannot write to a URI that has already been read":
I am not sure, but it sounds quite logical to me. A relative @href is resolved against the base output URI. So I think both the main output tree and the result-document would try to use the same URI, what is forbidden.
I personally would like like the default to be -vlax
+1
One last thing, an inbuilt "xslt 2.0" file/new template would be great
+1 Regards, -- Florent Georges http://www.fgeorges.org/

On Tue, Oct 28, 2008 at 12:22 PM, Andrew Welch <andrew.j.welch@gmail.com> wrote:
Hi,
Congratulations on integrating Saxon-SA - a great move!
I think there is a slight issue, this stylesheet (when run against itself with no output file given) causes the exception "Cannot write to a URI that has already been read":
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/"> <xsl:result-document validation="strict"> <foo/> </xsl:result-document> </xsl:template>
</xsl:stylesheet>
Well XSLT 2.0 Spec says [[ The href attribute is optional. The default value is the zero-length string. The effective value of the attribute must be a URI Reference, which may be absolute or relative. There may be implementation-defined restrictions on the form of absolute URI that may be used, but the implementation is not required to enforce any restrictions. Any legal relative URI must be accepted. Note that the zero-length string is a legal relative URI. ]] it means that absence of @href is equivalente to "" which means the base URI so the document itself So the error is ok from this perspective Regards, Xmlizer

I think there is a slight issue, this stylesheet (when run against itself with no output file given) causes the exception "Cannot write to a URI that has already been read":
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/"> <xsl:result-document validation="strict"> <foo/> </xsl:result-document> </xsl:template>
</xsl:stylesheet>
Well
XSLT 2.0 Spec says
[[ The href attribute is optional. The default value is the zero-length string. The effective value of the attribute must be a URI Reference, which may be absolute or relative. There may be implementation-defined restrictions on the form of absolute URI that may be used, but the implementation is not required to enforce any restrictions. Any legal relative URI must be accepted. Note that the zero-length string is a legal relative URI. ]] it means that absence of @href is equivalente to "" which means the base URI so the document itself
So the error is ok from this perspective
That doesn't seem right to me - you can never write to the same URI, so why would @href be optional? I'll raise it on the xsl-list... -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/

I'll raise it on the xsl-list...
Actually it's only fair to give the oXygen team a chance to respond - I'm pretty sure I'm right (!), it's implied with the default output anyway. An xsl:result-document with no @href is just making it explicit. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/

Hi Andrew, If no output is specified for the result of a transformation oXygen sets the system ID as the stylesheet for the virtual result that is presented in the oXygen results area. That is why you get that error message. Without setting a system identifier for the output it would have not been possible to use relative locations for result document without setting an output destination in the transformation scenario. We will consider making the system id of the result visible and configurable in the transformation scenario. Best Regards, George -- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com Andrew Welch wrote:
I'll raise it on the xsl-list...
Actually it's only fair to give the oXygen team a chance to respond - I'm pretty sure I'm right (!), it's implied with the default output anyway. An xsl:result-document with no @href is just making it explicit.

If no output is specified for the result of a transformation oXygen sets the system ID as the stylesheet for the virtual result that is presented in the oXygen results area. That is why you get that error message. Without setting a system identifier for the output it would have not been possible to use relative locations for result document without setting an output destination in the transformation scenario.
Hi George, I think the point is that: <xsl:template match="/"> <foo/> </xsl:template> and <xsl:template match="/"> <xsl:result-document> <foo/> </xsl:result-document> </xsl:template> ...are equivalent - the output URI is the same in both cases - so the exception shouldn't occur. Fwiw, I do the same in Kernow (although it's been a while since I wrote it and its all a bit hazy now) - when no output file is specified (so all output goes to standard out) the base output uri is the systemId of the stylesheet.... and in Kernow it seems fine. I basically do: controller.setBaseOutputURI(stylesheet.getSystemId()); ....with the Result being a StreamResult(System.out). -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/

mozer wrote:
it means that absence of @href is equivalente to "" which means the base URI so the document itself
But which document? The paragraph just below the one you quote tells: "If the effective value is a relative URI, then it is resolved relative to the base output URI." Because the example Andrew gave us doesn't generate anything in the output tree, just a result-document, maybe it is legal? But I think more like Andrew: maybe making @href optional doesn't make sense? I guess that's a question for XSL List. Regards, -- Florent Georges http://www.fgeorges.org/

But I think more like Andrew: maybe making @href optional doesn't make sense? I guess that's a question for XSL List.
No it makes sense that it's optional to me - it doesn't make sense if omitting it returns the URI of the stylesheet. I've always understood it to be relative to the output URI, and the error in this case will be down to the way oXygen handles the output behind the scenes (I'm guessing it's that, anyway, not much point in speculating further) Another way of looking at it is: <xsl:template match="/"> </xsl:template> and <xsl:template match="/"> <xsl:result-document> </xsl:result-document> </xsl:template> are equivalent where the xsl:result-document instruction is implied in the first instance, and explicit in the second. Both create document nodes in the result tree. It's like: <xsl:variable> </xsl:variable> and <xsl:variable> <xsl:document> </xsl:document> </xsl:variable> ...both are the same, where the document-node() creation is implied in the first, and explicit in the second. Again, that's just the way I see it. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/

Andrew Welch wrote:
But I think more like Andrew: maybe making @href optional doesn't make sense? I guess that's a question for XSL List.
No it makes sense that it's optional to me - it doesn't make sense if omitting it returns the URI of the stylesheet.
Well, returning the URI of the stylesheet sounds weird to me. If the @href effective value is a relative URI, it is resolved against the base output URI. While it is implementation-defined, I would be surprised by an implementation setting the base output URI to the stylesheet URI.
Another way of looking at it is:
<xsl:template match="/"> </xsl:template>
and
<xsl:template match="/"> <xsl:result-document> </xsl:result-document> </xsl:template>
are equivalent where the xsl:result-document instruction is implied in the first instance, and explicit in the second. Both create document nodes in the result tree.
More exactly both create a final result tree (and the former will create a final result tree only if it is the initial template.) So really, I don't see the usefulness of having @href optional (but I think I don't have enough imagination here.) Regards, -- Florent Georges http://www.fgeorges.org/

Hello, We will add a third option for skip validation and we will use radio buttons for the Saxon SA specific validation options. Lax validation will be the default instead of strict validation. The template for new XSLT 2.0 stylesheets will include the XML Schema namespace. Thank you for pointing them out, Sorin Andrew Welch wrote:
Also, in the "Saxon SA" specific options, -val and -vlax should be radio buttons shouldn't they (with a third option for skip)? I personally would like like the default to be -vlax rather than -val, otherwise you are forced to disable it if you want to use Saxon SA but aren't using input validation.
One last thing, an inbuilt "xslt 2.0" file/new template would be great, with:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
participants (5)
-
Andrew Welch
-
Florent Georges
-
George Cristian Bina
-
mozer
-
Sorin Ristache