What is MIME type "text/xquery"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

text/xquery is a MIME type for files that contain XQuery code. XQuery is used to process XML data.


It tells programs that the file is plain text with commands to query and transform XML. This helps code editors highlight the syntax correctly and allows servers or processors to treat the file as an XML query script.


Key functionality includes:


Files like XQL, XQ, XQM, XQUERY, or XQY use this MIME type.


This classification enhances interoperability and ensures that tools recognize and treat XQuery scripts in the correct manner. More details on XQuery are available at W3C XQuery.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: text/xquery    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="text/xquery">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'text/xquery');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

What is the text/xquery MIME type used for?

The text/xquery MIME type indicates that a file contains XQuery source code, a functional language used to query and transform XML data. Using this specific type allows web servers and applications to distinguish these scripts from standard text files or XML documents.

How do I configure Apache to serve XQuery files?

To associate XQuery extensions with this MIME type in Apache, add the following line to your .htaccess file or main configuration: AddType text/xquery .xq .xquery .xql. This ensures the server sends the correct Content-Type header instead of defaulting to plain text.

Can web browsers execute text/xquery files?

No, standard web browsers (like Chrome or Firefox) do not natively execute XQuery scripts. These files are typically processed server-side by XML databases (like BaseX or eXist-db) or processors to generate HTML or JSON, which is then sent to the browser.

What are the common file extensions for this MIME type?

The most frequently used extensions are .xq and .xquery. However, you may also encounter .xql, .xqm (often used for library modules), and .xqy depending on the specific environment or developer preference.

Is text/xquery safe to expose publicly?

Generally, you should not expose the raw source code of server-side scripts to the public. If a server is misconfigured to serve text/xquery files as downloadable text rather than executing them, it could reveal sensitive database logic or structural information to attackers.

How do I add text/xquery support to Nginx?

In Nginx, you should verify or update your mime.types file to include the mapping. Add the line text/xquery xq xquery xqm; inside the types block to ensure Nginx serves these files with the correct headers.

What software can open or edit text/xquery files?

Since text/xquery is a plain text format, you can view it in any basic text editor like Notepad. However, developers typically use advanced editors like VS Code or Oxygen XML Editor which provide syntax highlighting and debugging tools specific to the XQuery language.

What is the difference between text/xquery and application/xquery?

Both MIME types refer to the same content, but text/xquery is generally preferred because XQuery is a human-readable format. The text/* hierarchy indicates that the file can be read without binary decoding, whereas application/* is often used for binary data or files requiring specific runtime environments.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.