[Home] [By Thread] [By Date] [Recent Entries]
It's not a good idea to do something involving side-effects while
evaluating a variable, because optimizers tend to assume that evaluating
a variable is something they can do as and when and as often as they
please. If the variable isn't used, it's very likely that it will never
be evaluated; if two variables are involved, it's unpredictable which
order they will be evaluated in. In some cases an optimizer might decide
to evaluate a variable repeatedly rather than allocating memory to hold
its value.
It might not seem an obvious approach, but my suggestion would be to do this using xsl:result-document. That's about the closest XSLT gets to an instruction designed to have side effects, and there are rules about its behaviour designed to limit the damage that optimizers can do. There's still no absolute rule ensuring the order in which different result documents are generated (in recent Saxon releases, you can create lots of result documents in parallel), but at least there's a reasonable chance that each one will be written exactly once. In Saxon there's a mechanism (the OutputURIResolver) that allows the Java application to intercept calls to xsl:result-document. So by encapsulating the information needed by the application within the URI given to the result document (or putting it within the document itself) you can use xsl:result-document as a way of saying "here's some information, please process it in the background". Michael Kay Saxonica On 12/06/2012 16:07, Ming Yu wrote: Sorry if this is a very simple question but I couldn't seem to come up with a neat solution.
|

Cart



