I am using the function below, but not sure about it is always secure... Is it? No DOM-memory or "residual XSLT" at there?
function XSLproc_reuse($domXsl) {
static $XSLproc=NULL;
if (!$XSLproc)
$XSLproc = new XSLTProcessor();
return $XSLproc->importStylesheet($domXsl); // STABLE?
}
There are no future "surprise side effects" on it?
PS: I have some strange bugs with my XSLT processing... So, posting one (of many other) hypothesis here, to check if ok or must be avoid. This is more evident with XPath, see this other related question.
Another way, to REUSE MORE processing sheet (that I was using on my library), is to reuse also the imported XSLT:
function XSLproc_reuse2($nameOrDomXsl='', $domXsl=NULL) {
static $XSLproc=NULL;
static $name='';
if (!$XSLproc)
$XSLproc = new XSLTProcessor();
// else reune of the already initialized $XSLproc.
if (is_object($nameOrDomXsl))
return $XSLproc->importStylesheet($nameOrDomXsl); // STABLE?
elseif ($nameOrDomXsl==$name);
return $XSLproc; // imported in the last call, STABLE?
else { // recording for future reuse:
$name = $nameOrDomXsl;
return $XSLproc->importStylesheet($domXsl);
}
}