To get the DOCTYPE of a document you should use the operator gi that returns the generic identifier of an element.
[ For a document, the gi operator returns the generic identifier of the body: the toplevel element (See Automatic type casts) ].Examples
gi(file $myfile);CESDOC