Let's say I've designed a media type which is a strict subset of another media type. For example, my media type is application/vnd.example.foo+xml
(hereafter abbreviated foo+xml
). This media type is a strict subset of the application/xhtml+xml
(hereafter abbreviated xhtml
) media type. Basically my media type definition adds additional processing instructions (or replaces them completely) to certain constructs within the xhtml
media type. For the sake of example, it could say that in any foo+xml
documents, the xpath //ul[@class='foo']/li[a]
shall be shown in a specific way by clients, and the rest of the document shall be ignored, a processing model which is quite different from that of the original xhtml
media type.
Armed with this information, the server can now start creating representations of that type, and my clients can pass Accept headers and happily consume this type of document, both of them honoring the processing instructions laid out in my type definition. However, it's a custom media type which I can't assume anyone will know how to process.
An option that I have is this:
- When a client prefers the
foo+xml
media type, I serve the document with a Content-Type set to that media type. - When a client prefers the
xhtml
media type, I serve the same document with anxhtml
Content-Type header
This means that generic clients that don't know what foo+xml
but likely understand what xhtml
is can still process my document, follow links to other resources, present it to users in a generic fashion and so on. Likewise, a client that knows the semantics of foo+xml
can actually get a confirmation that this document is actually just that, instead of having to guess or introspect the document to see if it at all looks like something it can process (e.g. via HTML profiling, microformats, etc.).
- What are the pros and cons of doing this
- Is there prior art that echoes this technique?