Hi,
I've tried to find an answer to this everywhere but to now avail....

I have an XML/XSL file that displays a webpage. The XSL has :
<!--Refresh the page every X seconds-->
<META http-equiv="Refresh">
<xsl:attribute name="content">
<xsl:value-of select="//PageRefreshOverride"></xsl:value-of>
</xsl:attribute>
</META>

because I want the page to refresh every few seconds. The XML file is being updated by a .NET application about every 30 seconds. So basically I want the application to update the XML page and the page to refresh every about 30 seconds also to show the changes.

My problem is that every so often the refresh happens at the exact second that the XML is being written and the file isn't complete yet. It then displays the error:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

Is there a way to fix this because the update stops and the page never restarts the refresh process again.

regards
Dave

You probably need to modify your application so that it does the transformation also and just sends HTML to the webpage.

Thanks, but I can't really do that. The XSL needs to be available because the page must be easily configurable by the users. It doesn't sound like there is a nice answer to this so I'm going to change the App so it writes the XML out to a temp file and them does a simple file copy to the final location. This may limit the exposure to a half complete file.

Another possibility (untested) is for your App to create a lockfile while it is writing out the XML document and then remove the lockfile when the document write is completed. Within your XSL have a test to see if the lockfile exists and do nothing if it exists.

<xsl:variable name="lockexists">
      <xsl:choose>
         <xsl:when test="document('/tmp/lockfile')">true</xsl:when>
         <xsl:otherwise>false</xsl:otherwise>
      </xsl:choose>
   </xsl:variable>

The lockfile should be a simple XML document with a different namespace so that document() does not complain.

Ah Mr fpmurphy, very nice, I think that's a better solution. I'll do that, thanks for your help.
regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.