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:
<?php
$f = 'somestylesheet.xsl';
$xsl = DomDocument::loadXML(file_get_contents($f));
?>
document('other.xml') will not work with relative path and <?php $xsl = DomDocument::load($f); ?> will!