Unwanted XSLT caching when including XSLT's in other XSLT's?
Hi!
I'm having caching problems with my XSLT's. In this project I'm using XSLT includes for the first time and I'm suspecting this is what is causing my problems. In an XSLT I'm including two other XSLT's, like this:
The problem is that the mother XSLT seems to cache the content of the included XSLT's. The macro parameters of the mother XSLT's are set to the default values (Cache By Page = checked and Cache Period = 0).
The only way I have figured out to clear the cache is this:
Remove the includes from the mother XSLT
Save the mother XSLT
Reload the page on which the mother XSLT is used (then of course getting an XSLT error)
Paste the incudes back into the mother XSLT again
Save and reload - now it works - the caching is gone
This is a very "kludgy" way of doing it though and I would like to know if there's something else I can do? Altering the macro cache parameters? Using a different syntax for the includes?
It's indeed annoying, but I managed to get things working again just by saving the 'including' xslt again, for each change in the 'included' xslt's. So, i don't think you need the remove, save, paste, save pattern. A simple clicking on the save button of the 'includer' should be ok.
The <xsl:include> statement is very powerful, and also a bit annoying because xslt's are compiled when saving, but not every time they are run (which would defeat the purpose).
So... if you update the include'd file, you must then open and save each xslt that relies on it so that it "knows" about the changes in the included file. But if you update the main xslt file (and not an included file) then you only need save the main xslt file.
Some sort of dependency checker would be awesome, though I don't know if it's possible/practical.
Personally, I make a note in the included file(s) that mentions which xslt files reference it so that I can open/save them when I update the include file. And I don't bother to open/save any main xslt files that aren't using the updated functions in my include'd file because not all the functions (errr, 'templates') are referenced by every macro.
So this is not a bug but rather a "feature" that has to do with compiling and performance. My main reason for using XSLT includes in this case was that I didn't want the same two functions (responsible for rendering page content elements) duplicated in 5-6 different places. If I want to alter a certain tag in a page content rendering function, I want to do that in one place only. The solution with an include solved this problem and was very elegant. But now I understand that it comes with a prize...
Adding a dependecy checker, like you suggest Doug, would be very nice. Still I suspect that it would add a new dimension of complexity.
Two scenarios:
You have several edited and unsaved XSLT scripts open in your editor. Then you edit a script that is included in these scripts. If you where to implement some sort of auto re-save/recompile function, there's a riskt that you save changes in the including scripts that the user doesn't want to save.
If the editing is done in an external editor (like Visual Studio), how would you trigger the re-save/recompile action?
Unwanted XSLT caching when including XSLT's in other XSLT's?
Hi!
I'm having caching problems with my XSLT's. In this project I'm using XSLT includes for the first time and I'm suspecting this is what is causing my problems. In an XSLT I'm including two other XSLT's, like this:
The functions inside these includes are then used by the "mother"-XSLT:
The problem is that the mother XSLT seems to cache the content of the included XSLT's. The macro parameters of the mother XSLT's are set to the default values (Cache By Page = checked and Cache Period = 0).
The only way I have figured out to clear the cache is this:
This is a very "kludgy" way of doing it though and I would like to know if there's something else I can do? Altering the macro cache parameters? Using a different syntax for the includes?
Thanks in advance!
/Thomas Kahn
Hi Thomas,
It's indeed annoying, but I managed to get things working again just by saving the 'including' xslt again, for each change in the 'included' xslt's. So, i don't think you need the remove, save, paste, save pattern. A simple clicking on the save button of the 'includer' should be ok.
Let me know if that works out for you as well.
Cheers,
/Dirk
The <xsl:include> statement is very powerful, and also a bit annoying because xslt's are compiled when saving, but not every time they are run (which would defeat the purpose).
So... if you update the include'd file, you must then open and save each xslt that relies on it so that it "knows" about the changes in the included file. But if you update the main xslt file (and not an included file) then you only need save the main xslt file.
Some sort of dependency checker would be awesome, though I don't know if it's possible/practical.
Personally, I make a note in the included file(s) that mentions which xslt files reference it so that I can open/save them when I update the include file. And I don't bother to open/save any main xslt files that aren't using the updated functions in my include'd file because not all the functions (errr, 'templates') are referenced by every macro.
Make sense?
cheers,
doug.
Thanks a million guys!
So this is not a bug but rather a "feature" that has to do with compiling and performance. My main reason for using XSLT includes in this case was that I didn't want the same two functions (responsible for rendering page content elements) duplicated in 5-6 different places. If I want to alter a certain tag in a page content rendering function, I want to do that in one place only. The solution with an include solved this problem and was very elegant. But now I understand that it comes with a prize...
Adding a dependecy checker, like you suggest Doug, would be very nice. Still I suspect that it would add a new dimension of complexity.
Two scenarios:
/Thomas Kahn
PS. Doug: You always make sense! :-)
Thanks Doug this just saved me exactly the same problem.
Hi everyone,
This was taken thoroughly care of once and for all by Pete Duncanson's Life-Saving package: XSLTouch.
Install and forget - it's that simple!
/Chriztian
is working on a reply...