Dave Johnson on open web technologies, social software and Java
This is the first in my series of Web Integration Patterns. Check out the intro at this URL http://rollerweblogger.org/roller/entry/web_integration_patterns
Use links as a way to integrate web sites & applications via navigation and relationships between resources.
The web is the web and hypertext is hyper because of links. Links allow for the most deep and also the most shallow forms of integration. Links enable navigation and with some discipline, links can also express relationships between resources. There are a variety of ways to express links; the standard and most popular way is to use HTML, but there are others and I’ll cover them below.
With links, you can provide navigation between web applications at the application, or the feature level. One example is providing a link from the blog application of a social software suite to the wiki, forums and other component applications. Another is providing a link from one application to one specific part or feature of another application. This type of linking is easy to implement but fairly shallow. It’s convenience and not much more.
What’s more useful and powerful, is using links to create meaningful relationships between the resources provided by web applications. For example, there's obvious value linking a defect in a bug tracking system to the source code changes that fixed the bug in a source code management system. Or, you might link a Requirement resource to the Work-Item resources that implement it. By the way, those example are drawn from the OSLC specs for ALM / PLM integration.
If you want to use links to establish relationships, then you do have to have some discipline about the URLs you offer and the URLs you link to. You have to treat links with the same rigor and respect you’d give primary and foreign keys in a relational database. For example, if you make a resource available in different formats, and each at a different URL, one that ends in “.html” and one with “.xml” and one with “.json” then you’ve got three URLs that refer same resource. In this case, it’s better to use Content Negotiation so you can offer one URL that others can use to link to the resource.
One way to get yourself some link discipline is to adopt Linked Data and the RDF data model, which ”extends the linking structure of the Web to use URIs to name the relationship between things as well as the two ends of the link.” See also the Web Annotations and Linked Data & REST pattern.
The standard way to represent links on the web is through HTML and in HTML, links are expressed in a variety of ways, via anchor tags, via image tags, the link tag and others. There are other standard ways to express links, but none as popular as HTML.
<link> links can specify not only the URL of the link but also the relationship type of the link, as well as content-type and language for the resource that lies at the other end of the link. For example, a link type of
rel=”next” indicates that a link points to the next page in a series of pages, or multi-page article. A link type of
rel=”stylesheet” indicates that the link is to style-sheet to be applied to the current page. There are a standard set of link relationship types in the HTML spec. Here's an example from this very blog page, the link to this blogs Atom feed:
<link rel="alternate" type="application/atom+xml" title="Recent Entries (Atom)" href="http://rollerweblogger.org/roller/feed/entries/atom" />
The Atom Syndication Format defines a
<link> element, modeled on the one in HTML. Atom adds a length attribute, the size in bytes of the resource at the other end of the link. Atom defines some new links types, alternate, related, self and enclosure. Atom also allows new links to be added and a Atom link-type registry is maintained at IANA.org. Here’s an example link from the Atom comments feed for this blog:
<link rel="alternate" type="text/html" href= "http://rollerweblogger.org/roller/entry/apache_roller_5_0_rc3#comment-12941523" />
Another standard way to express links is RDF, using any of the RDF serializations: RDF/XML, Turtle, N3 and soon, there will be a W3C standard for RDF/JSON. Yes, there will be a standard way to express links in JSON and that's good news. For now, we're stuck with RDF/XML. In RDF/XML a link is expressed via the
rdf:resource attribute, so for example a link from a Requirement to the user that created the requirement might look like this:
<dc:creator rdf:resource="https://localhost:9443/user/676" />
RDF (Wikipedia page) goes way beyond the couple dozen link attributes and relationship types provided by HTML and Atom. RDF provides ways to specify property values about any linked resource, and property values of each link. RDF also provides ways to define vocabularies of properties.
It's time to wrap-up. For better or worse, I’ve written more than I expected to write and I’m nowhere near done with the topic of links. I hope I’ve covered the important parts. Comments are open so please correct me and make suggestions if you got some. This is the first pattern that I’ve written up, so I’m also interested in comments about the format, level of abstraction, value, etc. as well.
Next up: Common Navigation.