380 likes | 390 Vues
This article discusses the techniques of embedding semantic web data using RDFa and GRDDL, including examples and syntax for both approaches. It explores how to extract relevant portions of XML documents and make them available to Semantic Web agents, as well as how to store structure in attributes and set namespaces for RDFa.
E N D
Semantic Web in Depth RDFa, GRDDL and POWDER Dr Nicholas Gibbins - nmg@ecs.soton.ac.uk2013-2014
Embedding Semantic Web Data http://www.flickr.com/photos/40472757@N07/4508416502/
Embedded Data • Publishing patterns for linked data that we’ve already considered make the assumption that we’re publishing directly in RDF/OWL • What if the data already exists in a web resource, in some form?
Embedded Data • Republishing the data separately introduces redundancy, and the possibility of inconsistency - embed our SW data in the web resource • Two main approaches: • GRDDL • RDFa
GRDDL • Given a document in some XML format, how can we extract the relevant portions and make them available to SW agents? • GRDDL (Gleaning Resource Descriptions from Dialects of Languages) uses XSLT stylesheets to transform documents XSLTstylesheet XML doc RDF/XML GRDDL Processor
Using GRDDL with XML In well-formed XML, link to XSLT transformation using grddl:transformation attribute • Need to introduce grddl: namespace <html xmlns=‘http://www.w3.org/1999/xhtml’xmlns:grddl='http://www.w3.org/2003/g/data-view#’grddl:transformation="glean_title.xsl”> <head> <title>Are You Experienced?</title> [...]</html>
Using GRDDL with XHTML Link to XSLT transformation using link element • Introduce GRDDL in profile <html xmlns="http://www.w3.org/1999/xhtml”> <head profile="http://www.w3.org/2003/g/data-view”> <title>Some Document</title><link rel="transformation”href="http://www.w3.org/2000/06/dc-extract/dc-extract.xsl" /><meta name="DC.Subject” content="ADAM; Simple Search; Index+; prototype" /> [...] </head> [...]</html>
RDFa Yet another syntax for RDF… • Designed for embedding structured data in web pages • Stored structure in attributes (the ‘a’ in ‘RDFa’)
RDFa Example <html> <head><title>Jo's Friends and Family Blog</title></head> <body> <p>I'm holding one last summer Barbecue, on September 16th at 4pm.</p><p class="contactinfo”>Jo Smith. Web hacker at Example, Inc. You can contact me <a href="mailto:jo@example.org">via email</a>.</p></body></html>
Setting namespaces <html prefix=“cal: http://example.org/ontology/cal#foaf: http://xmlns.com/foaf/0.1/xsd: http://www.w3.org/2001/XMLSchema#”> <head><title>Jo's Friends and Family Blog</title></head> <body> <p>I'm holding one last summer barbecue, on September 16th at 4pm.</p> <p class="contactinfo”>Jo Smith. Web hacker atExample, Inc. You can contact me <a href="mailto:jo@example.org">via email</a>.</p> </body></html>
Showing an instance of a class Class membership is indicated using the typeof attribute: <p>I'm holding one last summer barbecue, on September 16th at 4pm.</p>
Showing an instance of a class Class membership is indicated using the typeof attribute: <p typeof=“cal:Event”>I'm holding one last summer barbecue, on September 16th at 4pm.</p> _:a rdf:typecal:Event.
Using properties: predicates The predicate of a triple is indicated using the property attribute: <p>I'm holding one last summer barbecue, on September 16th at 4pm.</p>
Using properties: predicates The predicate of a triple is indicated using the property attribute: <p>I'm holding <span property=“cal:summary”>one last summer barbecue</span>, on September 16th at 4pm.</p>
Using properties: literal objects The object of a literal-valued triple is given by the content of the element bearing the property attribute <p>I'm holding <span property=“cal:summary”>one last summer barbecue</span>, on September 16th at 4pm.</p> _:a cal:summary“one last summer barbecue” .
Using properties: substitute values The content of an element may be substituted for using the content attribute: <p>I'm holding one last summer barbecue, on <span property=“cal:start” content=“2007-09-16T16:00:00”>September 16th at 4pm</span>.</p> _:a cal:start“2007-09-16T16:00:00”.
Using properties: datatypes The datatype of a literal-value object is indicated using the datatypeattribute: <p>I'm holding one last summer barbecue, on <span property=“cal:start” datatype=“xsd:dateTime”content=“2007-09-16T16:00:00”>September 16th at 4pm</span>.</p> _:a cal:start “2007-09-16T16:00:00”^^xsd:dateTime.
Using properties: resource objects The object of a resource-valued triple is given by the content of the resource attribute: <p class="contactinfo”>Jo Smith. Web hacker at <span property=“foaf:workplaceHomepage” resource=“http://example.org”>Example, Inc</span>. You can contact me <a href="mailto:jo@example.org">via email</a>.</p> _:b foaf:workplaceHomepage<http://example.org/> .
Identity The subject of a triple is indicated using the about attribute: <p class="contactinfo”>Jo Smith. Web hacker at <span property=“foaf:workplaceHomepage” resource=“http://example.org”>Example, Inc</span>. You can contact me <a href="mailto:jo@example.org">via email</a>.</p> _:b foaf:workplaceHomepage <http://example.org/> .
Identity The subject of a triple is indicated using the about attribute: <p class="contactinfo” about=“http://example.org/staff/jo”>Jo Smith. Web hacker at <span property=“foaf:workplaceHomepage” resource=“http://example.org”>Example, Inc</span>. You can contact me <a href="mailto:jo@example.org">via email</a>.</p> <http://example.org/staff/jo>foaf:workplaceHomepage <http://example.org/> .
Using existing links Existing links may be used to construct triples with resource-valued objects: <p class="contactinfo” about=“http://example.org/staff/jo”>Jo Smith. Web hacker at Example, Inc. You can contact me <a href="mailto:jo@example.org">via email</a>.</p>
Using existing links The rel attribute is used to indicate the predicate: <p class="contactinfo” about=“http://example.org/staff/jo”>Jo Smith. Web hacker at Example, Inc. You can contact me <a rel=“foaf:mbox”href="mailto:jo@example.org">via email</a>.</p>
Using existing links The href attribute is used to indicate the object: <p class="contactinfo” about=“http://example.org/staff/jo”>Jo Smith. Web hacker at Example, Inc. You can contact me <a rel=“foaf:mbox” href="mailto:jo@example.org">via email</a>.</p> <http://example.org/staff/jo> foaf:mbox <mailto:jo@example.org> .
Original File <html> <head><title>Jo's Friends and Family Blog</title></head> <body> <p>I'm holding one last summer barbecue, on September 16th at 4pm.</p> <p class="contactinfo”>Jo Smith. Web hacker at Example, Inc. You can contact me <a href="mailto:jo@example.org">via email</a>.</p> </body></html>
Annotated File <html prefix=“cal: http://example.org/ontology/cal#foaf: http://xmlns.com/foaf/0.1/xsd: http://www.w3.org/2001/XMLSchema#”> <head><title>Jo's Friends and Family Blog</title></head> <body><p typeof=“cal:Event”>I'm holding <span property=“cal:summary”>one last summer barbecue</span>, on <span property=“cal:start”content=“2007-09-16T16:00:00” datatype=“xsd:dateTime”>September 16th at 4pm</span>.</p> <p class="contactinfo” typeof=“foaf:Person”about=“http://example.org/staff/jo”><span property=“foaf:name”>Jo Smith</span>. Web hacker at<span property=“foaf:workplaceHomepage” resource=“http://example.org”>Example, Inc</span>. You can contact me <a rel=“foaf:mbox”href="mailto:jo@example.org">via email</a>.</p> </body></html>
Contained Triples _:a rdf:typecal:Event ;cal:summary “one last summer barbecue” ;cal:start “2007-09-16T16:00:00”^^xsd:dateTime . <http://example.org/staff/jo> rdf:typefoaf:Person ;foaf:name “Jo Smith” ;foaf:workplaceHomepage <http://example.org> ;foaf:mbox <mailto:jo@example.org> .
Protocol for Web Description Resources RDF lets us make statements about a single resource at a time • an RDF triple has only one subject! POWDER is an XML format for describing groups of resources Lineage goes back to PICS – Platform for Internet Content Selection
OWL 1.1 Languages of the Semantic Web PICS MCF SHOE 1996 1997 1998 RDF(S) 1999 OIL DAML 2000 DAML+OIL 2001 2002 RDF(S) OWL 2003 2004 2005 2006 2007 W3C Language 2008 Other OWL 2 2009
General Syntax <powder> <attribution> //description of entity making the description </attribution> <dr> //description resource <iriset> //specifier for things being described </iriset> <descriptorset> // descriptions of things being described </descriptorset> </dr></powder>
General Syntax <powder><attribution> //description of entity making the description </attribution> <dr> //description resource <iriset> //specifier for things being described </iriset> <descriptorset> // descriptions of things being described </descriptorset> </dr></powder>
General Syntax <powder> <attribution> //description of entity making the description </attribution><dr> //description resource <iriset> //specifier for things being described </iriset> <descriptorset> // descriptions of things being described </descriptorset> </dr></powder>
General Syntax <powder> <attribution> //description of entity making the description </attribution> <dr> //description resource<iriset> //specifier for things being described </iriset> <descriptorset> // descriptions of things being described </descriptorset> </dr></powder>
General Syntax <powder> <attribution> //description of entity making the description </attribution> <dr> //description resource <iriset> //specifier for things being described </iriset><descriptorset> // descriptions of things being described </descriptorset> </dr></powder>
Example <?xml version="1.0"?><powder xmlns="http://www.w3.org/2007/05/powder#" xmlns:ex="http://example.org/vocab#"> <attribution> <issuedbysrc="http://authority.example.org/company.rdf#me" /> <issued>2007-12-14T00:00:00</issued> </attribution> <dr> <iriset> <includehosts>example.com</includehosts> </iriset> <descriptorset> <ex:color>red</ex:color> <ex:shape>square</ex:shape> <displaytext>Everything on example.com is red and square</displaytext> <displayiconsrc="http://authority.example.org/icon.png" /> </descriptorset> </dr> </powder>
Further Reading Gleaning Resource Descriptions from Dialects of LanguagesW3C Recommendation 11 September 2007http://www.w3.org/TR/grddl/ RDFaCore 1.1W3C Recommendation 22 August 2013http://www.w3.org/TR/rdfa-syntax/ RDFa1.1 Primer (essential reading!)W3C Working Group Note 22 August 2013http://www.w3.org/TR/xhtml-rdfa-primer/ POWDER PrimerW3C Working Group Note 1 September 2009http://www.w3.org/TR/powder-primer/