XML technologies / RSS & Atom / Atom / Structure of an Atom feed / Links in Atom
(Excerpt from "Newsfeeds with RSS and Atom" by Heinz Wittenbrink, published by Galileo Press, 2005)
In the examples so far, links occurred only as descendants of feed. The specification requires a link to an alternative web representation at least at feed level. (This requirement may become a recommendation: many Atom feeds carry content rather than describe content also available at other URIs.)
Although some Atom feeds contain few or no links, links play an important role in Atom. They support more functions than in other XML newsfeed applications, expressed through specific language features, usually different attribute values on the element link. An Atom link always explicitly states the relationship to its target resource.
In newer Atom specifications, links are defined by the element link rather than as a separate construct as in the earliest versions.
For links too, Atom’s authors sought to replace RSS ambiguities with clear element semantics. In RSS documents, the element link may point to related information or specify the URI of the item itself (or its HTML version). Nowadays they often hold so-called permalinks (although the element guid was also introduced for this purpose). In Atom, attributes borrowed from HTML identify a link’s target relationship, so the element link may also have the attributes href, rel, type and title in Atom.
Structure of an Atom link
Links describe a relationship between an Atom element and a web resource. The target resource’s URI is always the value of the attribute href of a link, rather than the content of the element link.
Like the HTML element link, in Atom link also has an attribute rel, whose value identifies the relationship type. Importantly, the attribute’s meaning is extensible: Atom specifies only a minimum. The values of rel are to be registered in future with IANA (Internet Assigned Numbers Authority). A name supplied as the value of rel must be interpretable as a name in the IANA Registry of Link Relations, yet to be established. It can then become a URI by appending it to the string "http://www.iana.org/assignments/relation/".
Some values are available from the outset and defined in Atom. They refer to the URI given as the value of href and describe the relationship between its resource and the feed or entry containing the link itself, as follows:
alternate: the URI identifies an alternative representation of the resource.related: the URI identifies a resource related to the resource containing thelink.self: the URI identifies the resource containing thelink.enclosure: the URI identifies a resource related to the resource containing thelink, which may be large and impose special requirements on processing software.via: the URI identifies a source for the information in the feed or entry containing thelink.
The attribute rel may be absent. In that case, the element link must be processed as if alternate were the value of rel.
The Atom Publishing Protocol defines further values for rel, expected to be registered with IANA soon. They describe relationships to URIs used to post and edit resources according to REST principles for web services. A URI for creating a resource with a POST request is given in a link whose attribute rel has the value resource.post. Another URI, "EditURI", edits a resource using HTTP PUT or deletes it using HTTP DELETE. The value of rel in this case is service.edit.
Links may also carry the optional attributes hreflang, title, type and length.
The value of the optional attribute hreflang specifies the target resource’s language, identified according to RFC 3066. If alternate is the value of rel, the resource is interpreted as a translation of the referring entry. Another optional attribute known from HTML is title on the element link.
The value of the attribute href is a URI reference (URI reference) as defined in the latest URI specification (RFC 2396). It may be a URI fragment resolved through a value in xml:base. If a link’s type is alternate, the given URI provides an alternative representation of the resource described in the parent of link, for example an HTML document. The value related indicates a relationship to the resource at the given URI. Entries or feeds about Google may, for example, contain the element <link rel="related" href="http://www.google.com">.
The attribute type on the element link contains the media or data type expected from the server when link is retrieved; this must be a registered MIME media type. A link can thus indicate, for example, that its target is a PDF document.
The value of the attribute title is a human-readable link title. The value of length may specify the target resource’s size in bytes. However, the values of length and type cannot guarantee that the retrieved document actually has the specified length and media type.
atom:link as a descendant of atom:feed
In all cases, a feed element must contain exactly one element of type title and one element of type link with the attribute value rel="alternate". (This rule may be revised before Atom Syndication Format 1.0 is published.) If this link points to an HTML element, meaning html is the value of the attribute type on the element link , the corresponding HTML element should link back to the feed, enabling Atom feed discovery through the specification’s autodiscovery mechanism. Further link elements are possible but must point to files of other types.
More explicitly than other feed formats, Atom thus defines a document as an alternative to another document.
Feed autodiscovery in Atom
Conversely, Atom also requires that a feed associated with an HTML element can be detected automatically. This uses the mechanism of feed autodiscovery, using the HTML element link. The value of rel on this HTML autodiscovery link is alternate, and the other attribute/value pair is type atom+xml. The value of href is the Atom feed’s URI. (HTML attribute values may use uppercase or lowercase, unlike the XML format Atom.)
An HTML document may also link to several Atom feeds, for example a weblog feed, an associated linkblog feed and a comments feed. The value of the attribute title, a human-readable link label, should clarify each feed’s contents. Automatic subscription uses the first link element, so the HTML author should place the most important feed first.
For the element link, see also the page atom:link in the Atom element reference.

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.