Re: [xsl] how to clear document buffer

Subject: Re: [xsl] how to clear document buffer
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 6 Nov 2002 22:26:08 -0700 (MST)
Ming Yu wrote:
> Hi,
> 
> What I need to do is to read the whole xml record from a database and write 
> it to a temporary file. And then, use the document function in the 
> stylesheet to read the file. The temporary file is rewritten depending on 
> the parameter I passed to the java method: $key.
> 
> This is what I'm doing:
> <xsl:variable name='record' 
> select="document(recsdetail:writeRecsXmlFile($recsTmpFile, $key))/xml"/>

Please note that the XML spec forbids the use of 'xml' at the beginning of an
element name, although it will not cause a well-formedness error, as they left
open the possibility for themselves to invent names with special semantics.
 
> The java method recsdetail:writeRecsXmlFile($recsTmpFile, $key) did the 
> reading from database and rewritting the temporary file which is the 
> $recsTmpFile. And then return the file name back which is the same as the 
> $recsTmpFile.
> 
> But the problem is that, although the temporary file did get rewritten, the 
> document function seems to see the same content every time.

The problem is your expectation that it will be different every time. In a
functional language, giving the same arguments to a function should always
produce the same result. The XSLT spec also explicitly states, in the section
about document(), "Two documents are treated as the same document if they are
identified by the same URI".

Have you investigated what it would take to extend the URI resolver class that
your XSLT processor uses? This varies from processor to processor, but if you
can do that, then you could make your own URI scheme, and have your resolver
process your custom URIs as necessary. The main thing the class need to do is
find the right document and return it as a stream. Check your processor docs.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread