Skip to content

XRD extensions for web applications

nevali edited this page Aug 17, 2010 · 3 revisions

Web applications, when executed, can register themselves using JavaScript as being able to handle specific MIME types and URI schemes. When a user later attempts to open a URI either using a registered scheme, or that is dereferenced to a resource of particular MIME type, the user is prompted to return to the web application using a URL template specified as part of the registration.

In some scenarios, it may not be advantageous for applications to be loaded (and so have their JavaScript execute) as a prerequisite for these registrations. One particular use-case is for applications made available by broadcasters (and other parties) to second-screen devices capable of presenting them. In these scenarios, the applications are not visited by the user in advance: their availability is advertised out-of-band, and in Project Baird this occurs through the use of XRD documents.

As such, this specification details the manner in which three different kinds of registration can be described by XRD documents, as a alternative to in-band registration through JavaScript.

The MIME type and URI scheme registrations occur in-band through the use of the following JavaScript APIs:

window.navigator.registerProtocolHandler(scheme, url, title);
window.navigator.registerContentHandler(mimeType, url, title);

This specification describes two XRD link relations which can be used in concert template attribute on the XRD Link element and Title and Property elements which are children of the Link.

Protocol (scheme) registrations

JavaScript:

window.navigator.registerProtocolHandler('sms', 'http://www.example.com/sendSms?destination=%s', 'Send a text message with Example, Inc.');

XRD:

<Link rel="http://projectbaird.com/ns/uriScheme" template="http://www.example.com/sendSms?destination=%s">
<Title>Send a text message with Example, Inc.</Title>
<Property type="http://projectbaird.com/ns/uriScheme" value="sms" />
</Link>

The key property - uriScheme could be included multiple times if desired, to allow for multiple registrations (this applies below also).

MIME type registrations

JavaScript:

window.navigator.registerContentHandler('text/directory', 'http://www.example.com/viewCard?card=%s', 'Add to your address book at Example, Inc.');

XRD:

<Link rel="http://projectbaird.com/ns/contentType" template="http://www.example.com/viewCard?card=%s">
<Title>Add to your address book Example, Inc.</Title>
<Property type="http://projectbaird.com/ns/contentType" value="text/directory" />
</Link>

Namespace registrations

Namespace registrations allow an application to register as a handler for all subjects which fall within the specified base URI. This has no parallel in the HTML5 JavaScript APIs, and is indented for user agents capable of building graphs (e.g., via RDF, or RDFa) relating to a resource which contain subject identifiers (for example, identifying topics or genres).

XRD:

<Link rel="http://projectbaird.com/ns/subjectNamespace" template="http://www.example.com/browse?subject=%s">
<Title>Explore with ExampleExplorer</Title>
<Property type="http://projectbaird.com/ns/subjectNamespace" value="http://www.bbc.co.uk/nature/" />
</Link>