Serving "application/tei+xml" from Cocoon

= How to serve TEI XML from Cocoon with the content-type "application/tei+xml" =

Most websites which publish TEI XML documents describe them with the content type "application/xml" or "text/xml". These are two labels for XML files in general, and don't identify the files as specifically TEI XML. By using the content type "application/tei+xml", a webserver can make the specific claim that the XML file is TEI rather than any other kind of XML. This has the advantage that browsers can be configured to handle TEI files distinctly from the way they handle other XML files (for instance, by opening them in an XML editor).

= Simple configuration =

To specify the content type, simply configure a serializer in your sitemap.xmap file, and then invoke the serializer in your TEI pipeline.

To declare the serializer:



Invoking the serializer:

= Preferred configuration =

Most browsers will adequately display generic XML but will not be configured to handle the specific content type "application/tei+xml". For this reason, it's usually better to serve the TEI as "application/tei+xml" only if the browser specifically asks for it, and otherwise to serve it as the generic "application/xml".

In Cocoon, you can use a RegexpHeaderSelector to determine if a browser is prepared to handle the specific content type. The following Cocoon sitemap shows a Reg

     application/tei\+xml accept

 

  