For those who wants to use external documents, it is important not to use the DomDocument::loadXML because the processor will not have the path to look for other files
So if you want to transform some xml with a pre-generated stylesheet $f:
$f = 'somestylesheet.xsl';
$xsl = DomDocument::loadXML(file_get_contents($f));
document('other.xml') will not work with relative path and
$xsl = DomDocument::load($f);
will!