If you want to use XXX mode for all files which end with the extension `.YYY', this will do it for you:
(setq auto-mode-alist (cons '("\\.YYY\\'" . XXX-mode) auto-mode-alist))
Otherwise put this somewhere in the first line of any file you want to edit in XXX mode:
-*-XXX-*-