Commit a5f2f9e adds a test for this bug. We should not only be checking:
<ptr target="thing.xml#subthing"/>
but also plain old:
<ptr target="thing.xml"/>
We should be using doc-available(), presumably. The question is whether we limit this to documents with known XML extensions. Checking binary files is notoriously hard (http://stackoverflow.com/questions/2917655/how-do-i-check-for-the-existence-of-an-external-file-with-xsl) but we could also have a list of known text file extensions and use unparsed-text-available() for those.