My handy-dandy XSL transformation fails to preserve <!DOCTYPE> declarations and &entity; usage as the XML parser reading the source XSL document expands entities before the transformer sees the content.
 
There doesn't seem to be a reasonable solution using standard tools.
 
The solution I'm considering now is to preprocess the file and turn <!DOCTYPE> and entities into processing instructions, do the transformation, and then postprocess the result to convert the processing instructions back to <!DOCTYPE> and entities.
 
Is there a better strategy that I'm not seeing?