The XSLTProcessor, when transforming a document, always resolves entities.
To avoid this (if you want to keep HTML entitities by ex.), you have two solutions:
- if you have full control over the input document, you can encapsulate every text element which contains entities in a CDATA section.
- the previous solution is the smarter and the less computing intensive, but it is not always possible. In other cases, what you can do is to replace every occurence of '&' (entity mark) by something which will be considered as normal text by the parser (let's say '[AMP]' by ex) in the input document before the transformation. After the transformation, you can get these entitites back in the output document by reversing the previous operation.
$xml = $input_dom->saveXML();
$xml = str_replace('&', '[AMP]', $xml);
$xml = $xsl->transformToXML($input_dom);
$xml = str_replace('[AMP]', '&', $xml);
Warning : this second method "escapes" ALL entities, even those you wouldn't want to be escaped. This is a raw explanation, fine-tune it to your own situation.