chickadee » atom » content-type

atom:contentrecord
content?procedure
content-kind Cprocedure
content-type Cprocedure
content-source Cprocedure
content-text Cprocedure
content-xhtml Cprocedure
content-xml Cprocedure
content-contents Cprocedure

Predicate and accessors for atom:content elements, which represent feed or entry content.

Atom content types may be one of "text", "html", "xhtml", or any valid MIME type; further, the structure and meaning of the content itself depends on the MIME type. To simplify this, we normalize the MIME type and we categorize it by kind:

type
The indicated MIME media type of the contents. If the type in the source document is text, html, or xhtml, we normalize this to text/plain, text/html, or application/xhtml+xml respectively. If no type is explicitly indicated, it defaults to text/plain.
kind
The computed "kind" of the contents, as a symbol. This determines how you should handle the content.

kind may be one of the following symbols, which represent

text
plain text (text/plain), the default
html
HTML text (text/html)
xhtml
an XHTML div element (application/xhtml+xml)
xml
XML; any MIME type string ending with /xml or +xml, or one of the RFC3023 XML media types
textual
text data; any other MIME type starting with text/
binary
base64-encoded binary data; any other MIME type other than those mentioned above
external
external data pointed to by a URI

To obtain the content, you should use the proper accessor based on the kind:

text
content-text, returning a string (or empty string, if no content)
html
content-text, returning an unescaped HTML string (or empty string)
xhtml
content-xhtml, returning the XHTML div element as SXML, or #f
xml
content-xml, returning the root element (whatever it is) as SXML, or #f [*]
textual
content-text, returning a string (or empty string)
binary
content-text, returning a base64-encoded string; use base64 to decode it
external
content-source, returning the external URI as a string, or #f

[*] XML contents conventionally consist of a single root element with no siblings, which is returned directly as (node ...). If more than one such element is found, they are all returned wrapped in a *TOP* node, like (*TOP* (node1 ...) (node2 ...) ...).

For xml, textual, binary and external kinds, you will then need to refer to the content media type to actually process it.

And finally the raw content accessor, just in case:

contents
Contents of the atom:contents element as a raw list of nodes. Does not try to process the content.