Copyright © tutorialspoint.com

What is Atom 1.0?

previous next


Advertisements

Atom is the name of an XML-based Web content and metadata syndication format, and an application-level protocol for publishing and editing Web resources belonging to periodically updated websites.

Atom is a relatively recent spec and is much more robust and feature-rich than RSS. For instance, where RSS requires descriptive fields such as title and link only in item breakdowns, Atom requires these things for both items and the full feed.

All Atom feeds must be well-formed XML documents, and are identified with the application/atom+xml media type.

Structure of an Atom 1.0 Feed:

A Feed consists of some metadata, followed by any number of entries. Here is a basic structure of an Atom 1.0 Feed

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title>...</title>
  <link>...</link>
  <updated>...</updated>
  <author>
    <name>...</name>
  </author>
  <id>...</id>

  <entry>
    <title>...</title>
    <link>...</link>
    <id>...</id>
    <updated>...</updated>
    <summary>...</summary>
  </entry>

</feed>

Atom 1.0 Feed Tags:

An Atom 1.0 Feed Document will be constructed of the following two elements:

There are some common construct which are required for the above two elements and they are explained in: Common Construct

<feed> Elements:

Feed ID:

This identifies the feed using a universally unique and permanent URI. If you have a long-term, renewable lease on your Internet domain name, then you can feel free to use your website's address.

Syntax:

<id>http://tutorialspoint.com/</id>

Required:

Required

Feed title:

This contains a human readable title for the feed. Often the same as the title of the associated website. This value should not be blank.

Syntax:

<title>Tutorials and Reference Manuals</title>

Required:

Required

Feed updatation Date:

Thsi indicates the last time the feed was modified in a significant way. All timestamps in Atom must conform to RFC 3339.

Syntax:

<updated>2007-07-13T18:30:02Z</updated>

Required:

Required

Feed Author:

This names one author of the feed. A feed may have multiple author elements. A feed must contain at least one author element unless all of the entry elements contain at least one author element.

An author element can have <name>, <email> and <uri> tags.

Syntax:

<author>
  <name>Mohtashim</name>
  <email>mohtashim@tutorialspoi.com</email>
  <uri>http://tutorialspoint.com/</uri>
</author>

Required:

Optional, but recommended

Feed link

This identifies a related Web page. The type of relation is defined by the rel attribute. A feed is limited to one alternate per type and hreflang. A feed should contain a link back to the feed itself.

Syntax:

<link>rel="self" href="/feed"</link>

Required:

Optional, but recommended

Feed Category:

This specifies a category that the feed belongs to. A feed may have multiple category elements.

Syntax:

<category>category term="sports"</category>

Required:

Optional

Feed Contributor:

This names one contributor to the feed. An feed may have multiple contributor elements.

Syntax:

<contributor>
  <name>Mohtashim</name>
</contributor>

Required:

Optional

Feed generator:

This identifies the software used to generate the feed, for debugging and other purposes. Both the uri and version attributes are optional.

Syntax:

<generator uri="/myblog.php" version="1.0">
  Example Toolkit
</generator>

Required:

Optional

icon Tag:

This identifies a small image which provides iconic visual identification for the feed. Icons should be square.

Syntax:

<icon>/icon.jpg</icon>

Required:

Optional

logo Tag:

This identifies a larger image which provides visual identification for the feed. Images should be twice as wide as they are tall.

Syntax:

<logo>/logo.jpg</logo>

Required:

Optional

rights Tag:

This conveys information about rights, e.g. copyrights, held in and over the feed.

Syntax:

<rights> © 2007 TutorialsPoint.com </rights>

Required:

Optional

subtitle Tag:

This contains a human-readable description or subtitle for the feed.

Syntax:

<subtitle>A sub title </subtitle>

<entry> Elements:

An Atom Feed may contain one or more entry elements. Here's a list of the required and optional feed elements.

Entry ID:

This Identifies the entry using a universally unique and permanent URI. Suggestions on how to make a good id can be found here. Two entries in a feed can have the same value for id if they represent the same entry at different points in time.

Syntax:

<id>http://example.com/blog/1234</id>

Required:

Required

Entry Title:

This contains a human readable title for the entry. This value should not be blank.

Syntax:

<title>Atom 1.0 Tutorial</title>

Required:

Required

Entry updation date:

This indicates the last time the entry was modified in a significant way. This value need not change after a typo is fixed, only after a substantial modification. Generally, different entries in a feed will have different updated timestamps.

Syntax:

<updated>2007-07-13T18:30:02-05:00</updated>

Required:

Required

Entry Author:

This names one author of the entry. An entry may have multiple authors. An entry must contain at least one author element unless there is an author element in the enclosing feed, or there is an author element in the enclosed source element.

Syntax:

<author>
  <name>Mohtashim</name>
</author>

Required:

Optional, but recommended

Entry Content:

This contains or links to the complete content of the entry. Content must be provided if there is no alternate link, and should be provided if there is no summary.

Syntax:

<content>complete story here</content>

Required:

Optional, but recommended

Entry link:

This identifies a related Web page. The type of relation is defined by the rel attribute. An entry is limited to one alternate per type and hreflang. An entry must contain an alternate link if there is no content element.

Syntax:

<link rel="alternate" href="/blog/1234"/>

Required:

Optional, but recommended

Entry summary:

This conveys a short summary, abstract, or excerpt of the entry. Summary should be provided if there either is no content provided for the entry, or that content is not inline.

Syntax:

<summary>Some text.</summary>

Required:

Optional, but recommended

Entry Category:

This specifies a category that the entry belongs to. A entry may have multiple category elements.

Syntax:

<category term="education"/>

Required:

Optional

Entry ontributor:

This names one contributor to the entry. An entry may have multiple contributor elements.

Syntax:

<contributor>
  <name>Mohtashim</name>
</contributor>

Required:

Optional

Published Tag:

This contains the time of the initial creation or first availability of the entry.

Syntax:

<published>2007-07-13T09:17:51-08:00</published>

Required:

Optional

Entry source:

If an entry is copied from one feed into another feed, then the source feed's metadata (all child elements of feed other than the entry elements) should be preserved if the source feed contains any of the child elements author, contributor, rights, or category and those child elements are not present in the source entry.

Syntax:

<source>
  <id>http://moretutorials.org/</id>
  <title>Tutorials and Reference Manuals</title>
  <updated>2007-07-13T18:30:02Z</updated>
  <rights>© 2007 More Tutorials.</rights>
</source>

Required:

Optional

Entry rights:

This conveys information about rights, e.g. copyrights, held in and over the entry.

Syntax:

<rights type="html">
  © 2007 TutorialsPoint.com
</rights>

Required:

Optional

Common Constructs:

Category

<category> has one required attribute, term, and two optional attributes, scheme and label.

term identifies the category

scheme identifies the categorization scheme via a URI.

label provides a human-readable label for display.

Content

<content> either contains, or links to, the complete content of the entry.

In the most common case, the type attribute is either text, html, xhtml, in which case the content element is defined identically to other text constructs, which are described here.

Otherwise, if the src attribute is present, it represents the URI of where the content can be found. The type attribute, if present, is the media type of the content.

Otherwise, if the type attribute ends in +xml or /xml, then an xml document of this type is contained inline.

Otherwise, if the type attribute starts with text, then an escaped document of this type is contained inline.

Otherwise, a base64 encoded document of the indicated media type is contained inline.

Link

<link> is patterned after html's link element. It has one required attribute, href, and five optional attributes: rel, type, hreflang, title, and length.

href is the URI of the referenced resource (typically a Web page)

rel contains a single link relationship type. It can be a full URI or one of the following predefined values (default=alternate):

type indicates the media type of the resource.

hreflang indicates the language of the referenced resource.

title human readable information about the link, typically for display purposes.

length the length of the resource, in bytes.

Person

<author> and <contributor> describe a person, corporation, or similar entity. It has one required element, name, and two optional elements: uri, email.

<name> conveys a human-readable name for the person.

<uri> contains a home page for the person.

<email> contains an email address for the person.

Text

<title>, <summary>, <content>, and <rights> contain human-readable text, usually in small quantities. The type attribute determines how this information is encoded (default="text")

If type="text", then this element contains plain text with no entity escaped html.

<title type="text">AT&amp;T bought by SBC!</title>

If type="html", then this element contains entity escaped html.

<title type="html">
  AT&amp;amp;T bought &lt;b&gt;by SBC&lt;/b&gt;!
</title>

If type="xhtml", then this element contains inline xhtml, wrapped in a div element.

<title type="xhtml">
  <div xmlns="http://www.w3.org/1999/xhtml">
    AT&amp;T bought <b>by SBC</b>!
  </div>
</title>

Check complete specification for atom 1.0 RFC4287.

Atom 1.0 Example Feed:

Here is the example feed files which shows how to write Feed using Atom 1.0

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title>Example Feed</title>
  <subtitle>Insert witty or insightful remark here</subtitle>
  <link href="http://example.org/"/>
  <updated>2003-12-13T18:30:02Z</updated>
  <author>
     <name>Mohtashim</name>
     <email>mohtashim@example.com</email>
  </author>
  <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>

  <entry>
     <title>Tutorial on Atom</title>
     <link href="http://example.org/2003/12/13/atom03"/>
     <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
     <updated>2003-12-13T18:30:02Z</updated>
     <summary>Some text.</summary>
   </entry>

</feed>

Atom1.0 File Extension:

A specific file-extension for an Atom 1.0 document is not required. But .xml is recommended.

previous next

Copyright © tutorialspoint.com