Project

Profile

Help

Results of URIResolver.resolve cached?

Added by Dan Daley over 11 years ago

I have written a custom URI resolver to resolve a few URIs of our own making. I want to be able to use something like this in my xsl document and have it resolved each time a transformation is run

<xsl:variable name="headersDoc" select="doc('repose:input:headers.xml')"/>

However, my URI resolver is only called on the first execution Subsequent executions use the results from the first resolve. Is there any way to have the result not cached?

I am using a SAX Reader with a series of XMLFilters to apply 0 or more xsl. I can post more information or code if helpful.

Thanks.


Replies (2)

RE: Results of URIResolver.resolve cached? - Added by Michael Kay over 11 years ago

Technically, the specification of the doc() function requires that if you call it twice with the same URI, you get the same document back - this means your program isn't at risk from optimizations like moving the call to a global variable. You can in fact get around this my using saxon:discard-document(doc(x)) which (conceptually) reads the document and then discards it from the cache. This does expose you to optimizations, however, such as moving the doc() call out of a loop or changing it to a global variable; you may need to watch out for this. Adding a "random" suffix to the URI (which your URIResolver can ignore) is often the best solution.

RE: Results of URIResolver.resolve cached? - Added by Dan Daley over 11 years ago

Thanks for the quick response. I have been adding a random UUID to the end of the URI, and that has been working. I'll probably try out the discard-document as an alternative.

    (1-2/2)

    Please register to reply