[xsl] Write to and read form same file

Subject: [xsl] Write to and read form same file
From: "Jesper Tverskov" <jesper@xxxxxxxxxxx>
Date: Thu, 20 Sep 2007 21:14:12 +0200
Hi List

In the XSLT 2.0 spec I have problems understanding the following:

"It is a recoverable dynamic error for a stylesheet to write to an
external resource and read from the same resource during a single
transformation, whether or not the same URI is used to access the
resource in both cases. The optional recovery action is
implementation-dependent: implementations are not required to detect
the error condition. Note that if the error is not detected, it is
undefined whether the document that is read from the resource reflects
its state before or after the result tree is written."

Is it a bug in XMLSpy 2008 that document() works anyway? It does not
in SAXON. Is it a bug in SAXON that collection() works anyway?

Here is a stylesheet for writing to and reading from same file both in
AltovaXML and SAXON:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
 <xsl:template match="/">
 <xsl:result-document href="test.xml">
  <xsl:when test="system-property('xsl:product-name') eq 'Altova XSLT Engine'">
  <!-- document() should return error in this case but it works (!) in
XMLSpy 2008 -->
   <xsl:value-of select="document('test.xml')/a/b"/>
  <xsl:when test="system-property('xsl:product-name') eq 'SAXON'">
  <!-- document() returns error as it should in SAXON. But
collection() works (!) -->
   <xsl:value-of select="collection(iri-to-uri('?select=test.xml'))/a/c"/>
   <warning>This code example does not include <xsl:value-of


Jesper Tverskov

Current Thread