Semantic Webapps? Lightweight RDF interfaces for SVG

Dan Brickley

Libby Miller

Submission to SVGOpen 2004, draft 2004-07-21


- format? (gcapaper format :/)
- usecases
- write the damn paper


  1. Introduction
  2. Usecases
  3. What does RDF give you in these examples?
  4. Why build it into SVG?
  5. Candidate APIs for RDF in SVG
  6. Conclusions and Further Work
  7. References


[This is the abstract]

SVG and RDF together provide the basis for the graphical user interfaces and abstract data models of next-generation Web applications. To fulfil this potential, SVG-based application developers will need to work with RDF data associated with SVG and raster image content. This paper outlines the current situation regarding RDF APIs and query languages, sketching a lightweight API design for SVG metadata access which is be consistent with the approaches used in systems such as Adobe's XMP system, Mozilla's XUL, and W3C's emerging RDF Data Access language and protocol.

W3C's Resource Description Framework (RDF) provides a set of conventions for mixing together descriptive data in XML. Although RDF is written in an XML syntax, the use of XML-level tools (DOM, SAX, XSLT) for accessing and manipulating RDF/XML documents can be problematic, since they can't directly exploit knowledge of RDF's abstract data model and schema languages (RDFS, OWL). The <metadata> tag in SVG encourages the use of W3C's Resource Description Framework (RDF) as an architecture for encoding metadata about SVG content and the things that such content represents. While the SVG DOM interface exposes the unprocessed RDF/XML through the SVGMetadataElement construct, there is potential for the creation of a simple, pragmatic RDF API that could be used to expose RDF metadata in terms of RDF concepts such as classes, properties and relationships.

An increasing number of documents and images contain RDF information relevant to SVG applications. There are a growing number of RDF "ontologies" which define vocabularies (associated with RDF/XML namespaces) each tuned to describing things in a particular domain. For example, the Dublin Core metadata vocabulary describes document-like objects, Creative Commons describes rights metadata. FOAF describes people and expresses homepage like content; XMP captures workflow information, SKOS represents thesaurus-based taxonomies, etc. Other RDF vocabularies address the descriptive needs of geographic and mapping apps, desktop tools (eg. Mozilla), and large scale taxonomies (Wordnet, TAP, Cyc, ...).

Almost all RDF APIs are designed such that the functions/methods are neutral regarding the RDF vocabularies they expose. This means that a single RDF API can be used to access a vast range of metadata fields: we don't need to define one API for rights metadata, another for RDF/EXIF, a third for content taxonomies. Furthermore, a basic interface to RDF data can be achieved with a single data access method. Even with refinements and convenience additions, there is a conceptual simplicity associated with RDF APIs, since they can all be understood in terms of sub-graph matching; either in terms of matching against a template RDF statement, or against a template RDF graph structure.

Embedded metadata may describe workflow properties, Exif data, creative commons information about allowable uses of the images, or user-defined RDF metadata about any aspect of the document or any other object, as RDF can be used to describe anything. There are also increasing numbers of self-contained RDF data documents on the web describing people, headlines and other entities relevant to SVG images yet not specifically image-centric. This information available could be made available to SVG applications via the SVG 1.2 getURL DOM interface.

At the time of writing, many RDF APIs exist but there is no one standard; work at W3C is currently focussed on a query language for RDF within the Data Access Working Group. However there is a great deal of implementation experience in multiple languages and applications, including Mozilla (specifically the XUL templating language) and in Abobe's XMP-reading software, as well as APIs in Javascript, Java, C#, C, C++, PHP.

In this paper we suggest some possible approaches to an RDF API for SVG based on current implementation experience. We argue that modest design effort and surprisingly simple technical details could provide us with an API for accessing RDF data within SVG, and that this would support a variety of interesting next-generation Web applications which combine the power of SVG graphics with RDF's data modelling and merging facilities.


Searching an images database

An SVG image search could search image metadata harvested from images or separate metadata files, and retrieve images appropriate to the search, displaying information about the image from the metadata embedded in the image or in a separate file. Examp les might include searching by date, by person, by location. RDF metadata can say anything about anything, so there are no constraints on how an image can be described or searched for.

This type of search service for images has been prototyped in html [Codepiction] and in SVG [SVG-Image-Search]. One advantage of an SVG version is the flexibility and creativity possible in displaying the images and associated information to the user.

Image filtering

As an extension of an image search, non-preferred images could be hidden by using filters on part or all of an image, by matching user preferences against metadata describing the image with respect to appropiateness for different age groups or preferen ces. A prototype has been created which shows the filtering of parts of an image. [SVG-Filter]

Display of geographical information

SVG and RDF can be used to display locative information on maps from multiple sources, downloaded as required, for example, reviews of restaurants by your friends, local transport data.

There are also potentially educational uses for geographical data expressed as RDF and simplayed using SVG, for example historical or political timelines of events; disputed events and territories.

Catalogues, instructions, accessibility

RDF can be used to specify an alternate image for a piece of text or vice-versa, which can be very valuable for accessibility purposes. Similarly text or more structured information can be specified for part of an image (for example using the parts of images RDF vocabulary [Image-Parts]).

What does RDF give you in these examples?

RDF provides a flexible, standard data model for describing objects and their relationships and properties, for example people and their friendships, calendars and homepages. RDF can be used to describe images and their EXIF properties but also much more gener al information about what is depicted in an image: real objects in the world such as people, animals, places.

The key strengths of RDF are the data model which underlies RDF and the extensibility and the ability to mix voacbularies together which comes from this solid foundation. RDF is designed so that the creation of vocabularies to describe parts of the world can b e distributed without breaking the fundamental RDF data model or causing problems for parsers and APIs. For example a person could take an EXIF schema describing image metadata and the extend it for some particular features of a specific camera, document the r elationship between this new vocabulary and the old one in an RDF Schema, and then expect that tools built with the EXIF schema in mind will either ignore the new properties or be able to process them using the RDF schema information. Conversely, RDF also makes mixing and reusing vocabularies created by different groups reasonably easy, again due to the mixture of the simple fundamental RDF data model the ability to document the relationships between vocabularies using RDF Schema. The ability to mix existing v ocabularies in a consistent fashion makes reuse of vocabularies easier.

RDF's strength in the usecases above comes from its distribted nature. RDF documents can be thought of as annotations, and these can be annotations of anything at all. THis means that different, possibly disputed, points of view can be expressed, shared, harvested and aggregated, but with an underlying common data model for description.

Why build it into SVG?

C is faster etc@@

Candidate APIs for RDF in SVG

A minimal API based on Jim Ley's Javascript RDF API

A minimal subset of Jim Ley's API would be 7 methods (paraphrasing slightly):@@check!

function getRDF(url,func)  [func is a call-back function]
function Match(s,p,o)
function subject();
function predicate();
function object();
function getType();
function getNodeValue();

as IDL defnitions of this subset: @@first pass@@ - added one more

interface RDF {
  void getRDFURL ( in DOMString uri, in EventListener callback );       
  RDFTripleList match ( in RDFNode subject, in RDFNode predicate, in RDFNode object); 
  //could also have factory methods here for creating nodes and/or triples
interface RDFTripleList {
  RDFNode getSubject (in unsigned long index);
  RDFNode getPredicate (in unsigned long index);
  RDFNode getObject (in unsigned long index);

//there's a sort of hidden obejct here, a triple. This is basically a list of triples

interface RDFNode {
  boolean getType();
  DOMString getNodeValue();
//could build on this for handling datatypes, langage tagging etc 

Mozilla XUL


var ds = RDF.GetDataSource(""); seems to be xul

Conclusions and Further work

Could the API as described support the following?

* transition path....Jim Ley's javascript API....
* the Triple object
* more specific graph operations, e.g. getSingleObject, Subject
* api-level creation, updating, replacing of triples
* provenance in apis
* queries
* literals: xmlliterals, lang, datatypes
* reification support
* RDFS support - subclasss and subproperties
* owl support
* simple inference operations
* serialization

Other stuff

* lots of RDF around - XMP
* Jan's document about rdf apis
* relationship to XBL?
* creative commons??
A future draft of this specification may list a set of property strings 
and expected results, such as the list of EXIF properties. (SVG 1.2)


* Jim's API
* SVG 1.2:
* DOM 3 IDLs
* Jan's api document: 


List of Jim Ley's js functions (not absolutely complete@@)

function getRDF(url,func)  [func is a call-back function]
function GetTriples()
function Match(triples,s,p,o)
function SingleObject(triples,s,p,o)
function SingleSubject(triples,s,p,o)

function outputNTriples()
function createPredicates(els)  ?
function getNamespaces(el)
function Triple(subject,predicate,object,type) 
function doSubProperties(triples)

sample code:
myRDF=new RDF();