Hi @johan. That looks like a bug to me. It seems that it creates an XML document as soon as there is something that looks like an XML tag (which happens sometimes, you know, in XQuery.) And it seems like it is not possible to decide explicitly the type of the document.
So I don’t think there is a workaround here, using only the QConsole creation mechanism. I see two solutions.
Manual creation
You can evaluate something like the following manually:
xdmp:document-insert(
'/some/stuff/todo.xqy',
text { 'xquery version "3.1";
declare module namespace ns = "...' })
This will give you a document with the right type: text. Make sure you pass everything every time (permissions, metadata, collections, etc.) as it overrides everything attached to the document, each time, not only the content.
ML Console
Alternatively, you can use the ML Console. Select your database, navigate through the directories, and create your document. You can select the right type at creation:
Note that it also gives you the ability to edit any document in place (as well as its permissions, metadata, collections, etc.), and also provides auto-completion for MarkLogic functions for JavaScript and XQuery files:
