The variable nxml-mode-map is defined in the library nxml-mode.
This library is not yet loaded when you try to execute the form
(define-key nxml-mode-map "\C-c t" 'tidy-xml).
Replace that line with:
(define-key nxml-mode-map "\C-c t" 'tidy-xml)))
That will delay the execution of the form contained in the ...
I ended up finding a suitable solution on another SO answer found here:
How to evaluate the variables before adding them to a list?
Return the argument, without evaluating it. (quote x) yields x.
Warning: quote does not construct its return value, but just returns
the value that was pre-constructed by the Lisp reader...
Hence, you ...