Facet Building Web Pages With SPARQL SWIG-UK Event, HP Labs November 23 rd  2007 Leigh Dodds Chief Technology Officer, Ingenta
Problem Statement
Where’s my RDF-native Web Framework?! There is no good system for integrating RDF repositories with existing an web framework (in Java)
Design Constraints
 
 
 
 
 
 
 
 
Design Constraints A web page presents data that is a sub-graph (i.e. a view) over a larger RDF store, (the  data model) The extent of the sub-graph may vary for different presentations of the data, and may contain arbitrary properties The description of the sub-graph (a  lens)  should be declarative That sub-graph is “rooted” on a single  primary resource  (e.g. a Journal) The identifier of the  primary resource  can be derived from the request URL, e.g. by rewriting the URI. And vice versa Therefore, we don’t support blank nodes as  primary resources Or fragment identifiers in URIs! The sub-graph should be  serializable  into an object graph for presentation to the templating system
Facet Request Handling To return a response we need to answer three questions… What  lens  are we going to apply? What  data model  are we going to apply it to? What’s the identifier of the  primary resource ?
Lenses Describing views of RDF data
A Simple Lens PREFIX dc:  <http://purl.org/dc/elements/1.1/> CONSTRUCT { ?item  dc:title ?title . ?item  dc:language ?language . }  WHERE { ?item  dc:title ?title . OPTIONAL { ?item dc:language ?language . }  }
Configuring Lenses <rdf:RDF  xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;  xmlns:ja=&quot;http://jena.hpl.hp.com/2005/11/Assembler#&quot;   xmlns:view=&quot;http://metastore.ingenta.com/facet/lens/&quot;> <rdf:Description  rdf:about=&quot;http://metastore.ingenta.com/facet/lens/Sparql&quot;>  <ja:assembler>com.ingenta.facet….</ja:assembler> </rdf:Description> <view:Sparql  rdf:about=&quot; http://oecd.metastore.ingenta.com/views/just-the-title &quot;> <view:query> sparql/just-the-title.rq </view:query> </view:Sparql> </rdf:RDF>
Data Model Configuring RDF graphs
Data Model Configuration Jena Assembler API Add notion of application level default data model Uses well-known URI Lenses may be configured to apply to a specific data model Allows “sharding” of data models <view:Sparql  rdf:about=&quot; http://oecd.metastore.ingenta.com/views/just-the-title &quot;> <view:appliesTo rdf:resource=“…”/> </view:Sparql>
Resource Identifiers
Mapping Resource Identifiers In a RESTful application, each resource should have a single primary location Allows resource identifiers to be derived using URL rewriting http://test.sourceoecd.org/oecd/content/journal/18168116 http://oecd.metastore.ingenta.com/content/journal/18168116
Serialization Mapping an RDF sub-graph to a Java object model
Serialization Primary resource is a  ContentItem Has an identifier and  Map  of properties Walk through graph, beginning at “root” resource, mapping RDF statements to Map entries Mapping of property names is configurable. Default based on namespace prefix, E.g.  dc_title Mapping of objects of each statement to a suitable Java object ContentItem, Map, List, Integer ,  etc
Serialization (special cases) Multilingual properties Special casing (i.e. a hack!) to modify naming, e.g.  dc_title_fr Repeated properties, e.g.  dc:subject Use schema annotation to indicate these, and then Serialize to a List XML Literals & Multi-lingual data E.g. multi-lingual abstracts ( dc:description ) that contain XHTML markup Use schema annotation, parse and create separate Map entries
Additional Features “ MultiLens”, applying multiple queries in series to build results Automatic availability of URL parameters as SPARQL query parameters Integral API support RDF output for free; JSON output trivial Simple content lifecycle, mapping to HTTP resource statuses E.g. Content Not Found, Moved, Gone Add type ( life:Deleted ) and properties ( life:newLocation ) to data Support for URL Aliasing based on property values /content/issn/1234-5678 -> /content/journal/abcdef <prism:issn>
Summary Pros By embracing a few limitations on RDF modelling, e.g. identifiers provides a very flexible means of building web pages from an RDF repository Reliance on SPARQL and Jena API features provides great deal of configuration options Good integration with existing web templating environments Quick to learn Cons Model limitations mean its not suited to all RDF “in the wild”

Facet: Building Web Pages with SPARQL

  • 1.
    Facet Building WebPages With SPARQL SWIG-UK Event, HP Labs November 23 rd 2007 Leigh Dodds Chief Technology Officer, Ingenta
  • 2.
  • 3.
    Where’s my RDF-nativeWeb Framework?! There is no good system for integrating RDF repositories with existing an web framework (in Java)
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
    Design Constraints Aweb page presents data that is a sub-graph (i.e. a view) over a larger RDF store, (the data model) The extent of the sub-graph may vary for different presentations of the data, and may contain arbitrary properties The description of the sub-graph (a lens) should be declarative That sub-graph is “rooted” on a single primary resource (e.g. a Journal) The identifier of the primary resource can be derived from the request URL, e.g. by rewriting the URI. And vice versa Therefore, we don’t support blank nodes as primary resources Or fragment identifiers in URIs! The sub-graph should be serializable into an object graph for presentation to the templating system
  • 14.
    Facet Request HandlingTo return a response we need to answer three questions… What lens are we going to apply? What data model are we going to apply it to? What’s the identifier of the primary resource ?
  • 15.
  • 16.
    A Simple LensPREFIX dc: <http://purl.org/dc/elements/1.1/> CONSTRUCT { ?item dc:title ?title . ?item dc:language ?language . } WHERE { ?item dc:title ?title . OPTIONAL { ?item dc:language ?language . } }
  • 17.
    Configuring Lenses <rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:ja=&quot;http://jena.hpl.hp.com/2005/11/Assembler#&quot; xmlns:view=&quot;http://metastore.ingenta.com/facet/lens/&quot;> <rdf:Description rdf:about=&quot;http://metastore.ingenta.com/facet/lens/Sparql&quot;> <ja:assembler>com.ingenta.facet….</ja:assembler> </rdf:Description> <view:Sparql rdf:about=&quot; http://oecd.metastore.ingenta.com/views/just-the-title &quot;> <view:query> sparql/just-the-title.rq </view:query> </view:Sparql> </rdf:RDF>
  • 18.
  • 19.
    Data Model ConfigurationJena Assembler API Add notion of application level default data model Uses well-known URI Lenses may be configured to apply to a specific data model Allows “sharding” of data models <view:Sparql rdf:about=&quot; http://oecd.metastore.ingenta.com/views/just-the-title &quot;> <view:appliesTo rdf:resource=“…”/> </view:Sparql>
  • 20.
  • 21.
    Mapping Resource IdentifiersIn a RESTful application, each resource should have a single primary location Allows resource identifiers to be derived using URL rewriting http://test.sourceoecd.org/oecd/content/journal/18168116 http://oecd.metastore.ingenta.com/content/journal/18168116
  • 22.
    Serialization Mapping anRDF sub-graph to a Java object model
  • 23.
    Serialization Primary resourceis a ContentItem Has an identifier and Map of properties Walk through graph, beginning at “root” resource, mapping RDF statements to Map entries Mapping of property names is configurable. Default based on namespace prefix, E.g. dc_title Mapping of objects of each statement to a suitable Java object ContentItem, Map, List, Integer , etc
  • 24.
    Serialization (special cases)Multilingual properties Special casing (i.e. a hack!) to modify naming, e.g. dc_title_fr Repeated properties, e.g. dc:subject Use schema annotation to indicate these, and then Serialize to a List XML Literals & Multi-lingual data E.g. multi-lingual abstracts ( dc:description ) that contain XHTML markup Use schema annotation, parse and create separate Map entries
  • 25.
    Additional Features “MultiLens”, applying multiple queries in series to build results Automatic availability of URL parameters as SPARQL query parameters Integral API support RDF output for free; JSON output trivial Simple content lifecycle, mapping to HTTP resource statuses E.g. Content Not Found, Moved, Gone Add type ( life:Deleted ) and properties ( life:newLocation ) to data Support for URL Aliasing based on property values /content/issn/1234-5678 -> /content/journal/abcdef <prism:issn>
  • 26.
    Summary Pros Byembracing a few limitations on RDF modelling, e.g. identifiers provides a very flexible means of building web pages from an RDF repository Reliance on SPARQL and Jena API features provides great deal of configuration options Good integration with existing web templating environments Quick to learn Cons Model limitations mean its not suited to all RDF “in the wild”