Should this now deleted answer, which was upvoted and had an auto-attributed bounty, but essentially was link-only, be deleted like any other link-only answer, or could it possibly be useful for anyone.
Breaking down the post leaves us with:
Define a custom EntityResolver.