[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Write to and read form same file

Subject: Write to and read form same file
From: "Jesper Tverskov" <jesper@xxxxxxxxxxx>
Date: Thu, 20 Sep 2007 21:14:12 +0200
 Write to and read form same file
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">
  <a>
   <b>Altova</b>
   <c>SAXON</c>
 </a>
 </xsl:result-document>
<test>
 <xsl:choose>
  <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>
  <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"/>
  </xsl:when>
  <xsl:otherwise>
   <warning>This code example does not include <xsl:value-of
select="system-property('xsl:product-name')"/>.<xsl:text/>
   </warning>
  </xsl:otherwise>
 </xsl:choose>
</test>
</xsl:template>
</xsl:stylesheet>

Cheers,

Jesper Tverskov
www.xmlplease.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.