Semantic TYPO3

60
Semantic TYPO3 Develop Extensions with Semantic Web in Mind Jochen Rau @ T3CON11SF June 11, 2011

description

Develop for TYPO3 with Semantic Web in mind.

Transcript of Semantic TYPO3

Page 1: Semantic TYPO3

Semantic TYPO3

Develop Extensions with Semantic Web in MindJochen Rau @ T3CON11SFJune 11, 2011

Page 2: Semantic TYPO3
Page 4: Semantic TYPO3
Page 5: Semantic TYPO3
Page 6: Semantic TYPO3
Page 7: Semantic TYPO3
Page 8: Semantic TYPO3

(c) by Benjamin Nowack, Attribution 3.0 Unported (CC BY 3.0)

Page 9: Semantic TYPO3

Concepts

(c) by Benjamin Nowack, Attribution 3.0 Unported (CC BY 3.0)

Page 10: Semantic TYPO3

Implementations

(c) by Benjamin Nowack, Attribution 3.0 Unported (CC BY 3.0)

Page 12: Semantic TYPO3

No Rocket Science

Page 13: Semantic TYPO3

Jochen's is a Person.Jochen's age is 40.Jochen's name is Jochen Rau.Jochen likes TYPO3 and Wine.Jochen lives in Massachusetts.

Let's make some assertions about me

Page 14: Semantic TYPO3

Jochen's is a Person.Jochen's age is 40.Jochen's name is Jochen Rau.Jochen likes TYPO3 and Wine.Jochen lives in Massachusetts.

Let's make some assertions about me

Subject Predicate Object

Page 15: Semantic TYPO3

Jochen's is a Person.Jochen's age is 40.Jochen's name is Jochen Rau.Jochen likes TYPO3 and Wine.Jochen lives in Massachusetts.

Let's make some assertions about me

Subject Predicate ObjectTriple

Page 16: Semantic TYPO3

Jochen's is a Person.Jochen's age is 40.Jochen's name is Jochen Rau.Jochen likes TYPO3 and Wine.Jochen lives in Massachusetts.

Let's make some assertions about me

Jochen 40

name Jochen Rau

age

TYPO3

WineMassachusetts

likeslikes

lives inPerson

is a

Page 17: Semantic TYPO3

Jochen's is a Person.Jochen's age is 40.Jochen's name is Jochen Rau.Jochen likes TYPO3 and Wine.Jochen lives in Massachusetts.

Let's make some assertions about me

Jochen 40

name Jochen Rau

age

TYPO3

WineMassachusetts

likeslikes

lives in

TYPO3

PHP

TYPO3 is a free and open source content management system as well as a Model–view–controller (MVC) Web Application Development framework written in PHP.

description

platform

GNU General Public License

license

Person

is a

Page 18: Semantic TYPO3

Jochen's is a Person.Jochen's age is 40.Jochen's name is Jochen Rau.Jochen likes TYPO3 and Wine.Jochen lives in Massachusetts.

Let's make some assertions about me

Jochen 40

name Jochen Rau

age

TYPO3

WineMassachusetts

likeslikes

lives in

TYPO3

PHP

TYPO3 is a free and open source content management system as well as a Model–view–controller (MVC) Web Application Development framework written in PHP.

description

platform

GNU General Public License

license

Person

is a

Page 19: Semantic TYPO3

Unique Names for Resources

Jochen

Sebastian

likes

knows

Paris

Page 20: Semantic TYPO3

Unique Names for Resources

<http://typoplanet.de/resource/Jochen>

<http://sebastian.kurfuerst.eu/>

<http://xmlns.com/foaf/0.1/knows>

<http://xmlns.com/foaf/0.1/likes>

<http://en.wikipedia.org/wiki/Paris_(2008_film)>

<http://sebastian.kurfuerst.eu/>

<http://typoplanet.de/resource/Jochen>

<http://typoplanet.de/resource/hg132k4jhjh1234t><urn:uuid:67ecc3bd-07e2-44f4-a788-597bf9949f0c>

<tel:+1-617-555-7332><mailto:[email protected]>

Page 21: Semantic TYPO3

Unique Names for Resources

<http://typoplanet.de/resource/Jochen>

<http://sebastian.kurfuerst.eu/>

<http://xmlns.com/foaf/0.1/knows>

<http://xmlns.com/foaf/0.1/likes>

<http://en.wikipedia.org/wiki/Paris_(2008_film)>

<http://sebastian.kurfuerst.eu/>

Page 22: Semantic TYPO3

<http://example.com/JR> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .

<http://example.com/JR> <http://xmlns.com/foaf/0.1/age> "40" .

<http://example.com/JR> <http://xmlns.com/foaf/0.1/name> "Jochen Rau" .

<http://example.com/JR> <http://xmlns.com/foaf/0.1/interest> <http://dbpedia.org/resource/TYPO3> .

<http://example.com/JR> <http://xmlns.com/foaf/0.1/interest> <http://dbpedia.org/resource/Wine> .

<http://example.com/JR> <http://example.com/livesIn> <http://data.nytimes.com/Massachusetts> .

Turtle Serialization of an RDF Graph

Page 23: Semantic TYPO3

@prefix ex: <http://example.org/> .@prefix dbp: <http://dbpedia.org/resource/> .@prefix nyt: <http://data.nytimes.com/> .@prefix foaf: <http://xmlns.com/foaf/0.1/> .

ex:JR a foaf:Person .ex:JR foaf:age "40" .ex:JR foaf:name "Jochen Rau" .ex:JR foaf:interest dbp:TYPO3 .ex:JR foaf:interest dbp:Wine .ex:JR ex:livesIn nyt:Massachusetts .

Turtle Serialization of an RDF Graph

Page 24: Semantic TYPO3

@prefix ex: <http://example.org/> .@prefix dbp: <http://dbpedia.org/resource/> .@prefix nyt: <http://data.nytimes.com/> .@prefix foaf: <http://xmlns.com/foaf/0.1/> .

ex:JR a foaf:Person ; ex:age "40" ; ex:name "Jochen Rau" ; ex:likes dbp:TYPO3 ; ex:likes dbp:Wine ; ex:livesIn nyt:Massachusetts .

Turtle Syntactic sugar

Page 25: Semantic TYPO3

@prefix ex: <http://example.org/> .@prefix dbp: <http://dbpedia.org/resource/> .@prefix nyt: <http://data.nytimes.com/> .@prefix foaf: <http://xmlns.com/foaf/0.1/> .

ex:JR a foaf:Person ; ex:age "40" ; ex:name "Jochen Rau" ; ex:likes dbp:TYPO3 , dbp:Wine ; ex:livesIn nyt:Massachusetts .

Turtle And even more syntactic sugar

Page 26: Semantic TYPO3

RDF at a Glance

Simple, ubiquitous way of modeling dataMain concepts

Triples of subject, predicate, and objectUnique names for resourcesObjects can also be literal values (with data type or language)

Performant data stores (e.g. Virtuoso, AllegroGraph, BigOWLIM)Existing frameworks with rich APIs (e.g. JENA, Sesame, Erfurt)Billions of triples as Open Data available (e.g. Wikipedia, MusicBrainz)Many di!erent serialization formats (e.g. RDF/XML, Turtle, N3)Makes data migration much easier

Page 27: Semantic TYPO3

Description Logic and Rules OWL and RIF

What? Why?Knowledge is spread all over the system:Domain model, database scheme, TS con"gurartion, FlexForm, TCA, documentation, Templates ...In di!erent Formats:SQL, TypoScript, XML, PHP, HTML ...Using inconsistent terminology:"Template" in TYPO3?

So, what to do?data and metadata in the same data structure (RDF)use well de"ned languages to describe (meta)data (OWL RIF)

Page 28: Semantic TYPO3

Knublauch, Holger. KBeans Specification: Semantic Transparency for Components and Domain Models. Technical Report FAW-TR-01001, FAW Ulm, 2001.

Description Logic and Rules OWL and RIF

Page 29: Semantic TYPO3

RDF in HTML

Three di!erent standards to markup your HTML codeMicroformatsMicrodata (part of HTML5 spec)RDFa ("RDF for attributes", W3C Recommendation)

A subset of RDFMakes web pages machine readable by your favorite search engine

Page 30: Semantic TYPO3

<div>

<p> Alice Birpemswick </p> <p> Email: <a href="mailto:[email protected]">[email protected]</a> </p> <p> Phone: <a href="tel:+1-617-555-7332">+1 617.555.7332</a> </p></div>

RDF in HTML RDFa

Page 31: Semantic TYPO3

<div prefix="foaf: http://xmlns.com/foaf/0.1/" about="http://example.com/resource/alice" typeof="Person"> <p property="foaf:name"> Alice Birpemswick </p> <p> Email: <a rel="foaf:mbox" href="mailto:[email protected]">[email protected]</a> </p> <p> Phone: <a rel="foaf:phone" href="tel:+1-617-555-7332">+1 617.555.7332</a> </p></div>

RDF in HTML RDFa

Page 32: Semantic TYPO3

<div prefix="foaf: http://xmlns.com/foaf/0.1/" about="http://example.com/resource/alice" typeof="Person"> <p property="foaf:name"> Alice Birpemswick </p> <p> Email: <a rel="foaf:mbox" href="mailto:[email protected]">[email protected]</a> </p> <p> Phone: <a rel="foaf:phone" href="tel:+1-617-555-7332">+1 617.555.7332</a> </p></div>

RDF in HTML RDFa

http://example.com/resource/alice

Page 33: Semantic TYPO3

<div prefix="foaf: http://xmlns.com/foaf/0.1/" about="http://example.com/alice#me" rel="knows"> <ul> <li typeof="Person"> <a rel="foaf:homepage" href="http://example.com/bob" property="foaf:name">Bob</a> </li> <li typeof="Person" > <a rel="foaf:homepage" href="http://example.com/eve" property="foaf:name">Eve</a> </li> <li typeof="Person" > <a rel="foaf:homepage" href="http://example.com/manu" property="foaf:name">Manu</a> </li> </ul></div>

RDF in HTML RDFa

Page 34: Semantic TYPO3

<div prefix="foaf: http://xmlns.com/foaf/0.1/" about="http://example.com/alice#me" rel="knows"> <ul> <li typeof="Person"> <a rel="foaf:homepage" href="http://example.com/bob" property="foaf:name">Bob</a> </li> <li typeof="Person" > <a rel="foaf:homepage" href="http://example.com/eve" property="foaf:name">Eve</a> </li> <li typeof="Person" > <a rel="foaf:homepage" href="http://example.com/manu" property="foaf:name">Manu</a> </li> </ul></div>

RDF in HTML RDFa

Page 35: Semantic TYPO3

RDF in HTML GoodRelations Vocabulary

Page 36: Semantic TYPO3

# Set the doctype and add common namespacesconfig.doctype = xhtml+rdfa_10config.namespaces { xml = http://www.w3.org/XML/1998/namespace xmlns = http://www.w3.org/2000/xmlns/ xsd = http://www.w3.org/2001/XMLSchema# xhv = http://www.w3.org/1999/xhtml/vocab# rdfa = http://www.w3.org/ns/rdfa# rdf = http://www.w3.org/1999/02/22-rdf-syntax-ns# rdfs = http://www.w3.org/2000/01/rdf-schema# owl = http://www.w3.org/2002/07/owl# rif = http://www.w3.org/2007/rif#

[...]

dbo = http://dbpedia.org/ontology/ foaf = http://xmlns.com/foaf/0.1/ geo = http://www.w3.org/2003/01/geo/wgs84_pos# gr = http://purl.org/goodrelations/v1# cal = http://www.w3.org/2002/12/cal/ical# og = http://ogp.me/ns# v = http://rdf.data-vocabulary.org/# bibo = http://purl.org/ontology/bibo/}

RDF in HTML Enable RDFa in TYPO3

Page 37: Semantic TYPO3

Demo

Page 38: Semantic TYPO3

EXT:semantic SPARQL Client

Page 40: Semantic TYPO3

Linked Data Cloud

Page 41: Semantic TYPO3

Querying a Graph SPARQL

W3C RecommendationGraph pattern matchingSimilar to SQL and Turtle

Page 42: Semantic TYPO3

Querying a Graph Filter, Functions, Ordering ...

Page 43: Semantic TYPO3

Querying a Graph Custom Functions

Page 44: Semantic TYPO3

Querying a Graph Property Paths

Page 45: Semantic TYPO3

Querying a Graph Property Paths and Inference

Page 46: Semantic TYPO3

Querying a Graph Subqueries

Page 47: Semantic TYPO3

EXT:semantic SPARQL Query Administration

Default namespaces(RDFa default pro"le)Syntax highlightingCode indentation

Content Manager

Page 48: Semantic TYPO3

EXT:semantic SPARQL Query Administration

Default namespaces(RDFa default pro"le)Syntax highlightingCode indentationFrontend and backend

Content Manager

Page 49: Semantic TYPO3

EXT:semantic Custom Content Elements

Default layouts and custom HTML template codeSupport for pagination (dynamic query re-writing)

Page 50: Semantic TYPO3

EXT:semantic Custom Content Elements

Frontend Backend

Page 51: Semantic TYPO3

EXT:semantic Custom Content Elements

Query results variables are bound to the template variablesand are used as labels in a human readable form

Page 52: Semantic TYPO3

Demo

Page 53: Semantic TYPO3

class Tx_BlogExample_Domain_Repository_PostRepository extends Tx_Extbase_Persistence_Repository {

public function findByTagAndBlog($tag, Tx_BlogExample_Domain_Model_Blog $blog, $limit = 20) { $query = $this->createQuery(); return $query->matching( $query->logicalAnd( $query->equals('blog', $blog), $query->equals('tags.name', $tag) ) ) ->setOrderings(array('date' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING)) ->setLimit((integer)$limit) ->execute(); }

public function findNext(Tx_BlogExample_Domain_Model_Post $post) { $query = $this->createQuery(); $posts = $query->matching($query->greaterThan('date', $post->getDate())) ->setOrderings(array('date' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING)) ->execute(); return $posts->getFirst(); }

}

Query Object Model

Developer

Page 54: Semantic TYPO3

Semantic TYPO3 Current Projects

SPARQL Client (EXT:semantic, Jochen Rau)RDF/RDFa support (Sebastian Kurfürst, masters thesis)CMS ontology (Andreas Wolf, GSoC)Taxonomy and Categories (EXT:taxonomy, Fabien Udriot)Semantic persistence backend (EXT:semantic, Thomas Maroschik)Globally unique identi"ers in v4 (EXT:identity, Thomas Maroschik)Tagging support for Editors (v4: RTE plugin, v5: Aloha)

Page 55: Semantic TYPO3

Semantic TYPO3 Roadmap

Improve usability of SPARQL ClientTransform Domain Models into RDF(a)Transform OWL Ontologies into PHP Code and MetadataExtbase Query Object Model -> SPARQL Query

Page 56: Semantic TYPO3

Semantic TYPO3 Vision

Page 57: Semantic TYPO3

Semantic TYPO3 Vision

Page 58: Semantic TYPO3

Semantic TYPO3 Vision

Page 59: Semantic TYPO3

Demo

Page 60: Semantic TYPO3

Thanks!

Twitter @jocrauEmail [email protected] http://blog.typoplanet.deTalk Lunch