How to consume Attention Profiling Markup Language (APML) formatted attention data

Attention Profiling Markup Language (APML) is an open standard that encapsulates a summary of your interests (across multiple profiles) in a simple, portable way. APML allows users to share their own personal attention profile in much the same way that OPML allows the exchange of reading lists between news readers. The idea is to compress all forms of attention data into a portable file format containing a description of ranked user interests.

Attention data comes in many forms. These include specifically designed, high-resolution file formats or more familiar forms of user data storage such as IM chat logs, browser history and cache, email inboxes, documents, OPML lists, etc. In some usage scenarios, however, it is necessary to analyze all available attention data to determine an attention profile, a compressed, portable and open-standard description of one’s ranked personal interests. A portable attention profile would allow a user to own (and optionally submit) a meta view of their interests to create instant relationships with "attention aware" products and services; and thus creates an instantly customized user experience.

The classes that together compose the implementation of APML are located in the Argotic.Syndication.Specialized namespace. The primary framework entity that you will use when working with APML formated syndication resources is the ApmlDocument class. This class implements the ISyndicationResource and IExtensibleSyndicationObject interfaces, and provides an API that maps closely to the syndication specification entities as well as methods for consuming and persisting syndicated attention data. The framework will by default automatically load any syndication extensions that are present in addition to the syndicated attention data and attempt to handle malformed XML data.

Discovery

The APML document representing a particular web resource can be found in the header of the page. It is represented by a HTML element that looks like this:
<link rel="meta" type="application/xml+apml" title="{Human readable label for attention data}" href="{Absolute URI that points to the APML formatted attention data}"/>

Example:
<link rel="meta" type="application/xml+apml" title="APML 0.6" href="http://apml.pbwiki.com/apml"/>

Consuming syndicated attention data

The ApmlDocument class provides two ways of consuming syndicated content that conforms to the APML syndication format. The first way to consume APML attention data is to use the static Create method exposed by the ApmlDocument class, which provides a means of quickly consuming attention data that is available at a given Uri:

using Argotic.Syndication.Specialized;

ApmlDocument document   = ApmlDocument.Create(new Uri("http://aura.darkstar.sunlabs.com/AttentionProfile/apml/web/Oppositional"));

foreach (ApmlProfile profile in document.Profiles)
{
    if (profile.Name == document.DefaultProfileName)
    {
        //  Perform some processing on the attention profile
        break;
    }
}


The other way to consume APML attention data is to use the overloaded Load method exposed by the ApmlDocument class, which provides a means of consuming syndicated attention data from a variety of data sources such as IXPathNavigable, Stream, XmlReader, and Uri:

using System.IO;
using System.Xml;
using System.Xml.Xpath;
using Argotic.Syndication.Specialized;

ApmlDocument document   = new ApmlDocument();

using (FileStream stream = new FileStream("SampleAttentionProfile.xml", FileMode.Open, FileAccess.Read))
{
    document.Load(stream);
}

document    = new ApmlDocument();
using (FileStream stream = new FileStream("SampleAttentionProfile.xml", FileMode.Open, FileAccess.Read))
{
    XmlReaderSettings settings  = new XmlReaderSettings();
    settings.IgnoreComments     = true;
    settings.IgnoreWhitespace   = true;

    using (XmlReader reader = XmlReader.Create(stream, settings))
    {
        document.Load(reader);
    }
}

document    = new ApmlDocument();
using (FileStream stream = new FileStream("SampleAttentionProfile.xml", FileMode.Open, FileAccess.Read))
{
    document.Load(new XPathDocument(stream));
}

Sample file that can be used with the above code example: SampleAttentionProfile.xml

Last edited Mar 24, 2008 at 10:32 PM by Oppositional, version 3

Comments

No comments yet.