web semantic

16
1. RDF Schema: Basic Ideas RDF is a universal language that lets users describe resources using their own vocabularies. RDF does not make assumptions about any particular application domain, nor does it define the semantics of any domain. Is it up to the user to do so in RDF Schema (RDFS). RDF Schema does not provide actual applicationspecific classes and properties. Instead RDF Schema provides the framework to describe applicationspecific classes and properties. Classes in RDF Schema are much like classes in object oriented programming languages. This allows resources to be defined as instances of classes, and subclasses of classes. 1.1 Classes and Properties A class can be thought of as a set of elements sharing properties. Individual objects that belong to a class are referred to as instances of that class. We have already defined the relationship between instances and classes in RDF using rdf:type. An important use of classes is to impose restrictions on what can be stated in an RDF document using the schema. In programming languages, typing is used to prevent nonsense from being written (such as A + 1, where A is an array; we lay down that the arguments of + must be numbers). The same is needed in RDF. 1.2 Class Hierarchies and Inheritance Once we have classes we would also like to establish relationships between them. For example, every professor is an academic staff member. We say that “professor” is a subclass of “academic staff member”, or equivalently, that “academic staff member” is a superclass of “professor”. The subclass relationship defines a hierarchy of classes. In general, A is a subclass of B if every instance of A is also an instance of B. There is no requirement in RDF Schema that the classes together form a strict hierarchy. A class may have multiple superclasses. If a class A is a subclass of both B1 and B2, this simply means that every instance of A is both an instance of B1 and an instance of B2. RDF Schema fixes the semantics of “is a subclass of”. Now it is not up to an application to interpret “is a subclass of”; instead its intended meaning must be used by all RDF processing software. By making such semantic definitions RDFS is a (still limited) language for defining the semantics of particular domains. Stated another way, RDF Schema is a primitive ontology language. In RDFS, properties are defined globally, that is, they are not encapsulated as attributes in class definitions. It is possible to define new properties that apply to an existing class without changing that class. Example of a hierarchy of classes

Upload: dan-tecu

Post on 16-Dec-2015

18 views

Category:

Documents


0 download

DESCRIPTION

RDF Schema

TRANSCRIPT

  • 1. RDF Schema: Basic Ideas RDF is a universal language that lets users describe resources using their own vocabularies. RDF does not make assumptions about any particular application domain, nor does it define the semantics of any domain. Is it up to the user to do so in RDF Schema (RDFS). RDF Schema doesnotprovideactualapplicationspecificclassesandproperties.Instead RDF Schema provides the framework to describe applicationspecific classes and properties.Classes in RDF Schema are much like classes in object oriented programming languages. This allowsresourcestobedefinedasinstancesofclasses,andsubclassesofclasses.

    1.1 Classes and Properties A class can be thought of as a set of elements sharing properties. Individual objects that belong to a class are referred to as instances of that class. We have already defined the relationship betweeninstancesandclassesinRDFusingrdf:type.An important use of classes is to impose restrictions on what can be stated in an RDF document using the schema. In programming languages, typing is used to prevent nonsense from being written (such as A + 1, where A is an array we lay down that the arguments of + must be numbers).ThesameisneededinRDF.

    1.2 Class Hierarchies and Inheritance Once we have classes we would also like to establish relationships between them. For example, every professor is an academic staff member. We say that professor is a subclass of academic staff member, or equivalently, that academic staff member is a superclass of professor. The subclass relationship defines a hierarchy of classes. In general, A is a subclass of B if every instance of A is also an instance of B. There is no requirement in RDF Schema that the classes together form a strict hierarchy. A class may have multiple superclasses. If a class A is a subclass of both B1 and B2, this simply means that every instance of A is both an instance ofB1andaninstanceofB2.RDF Schema fixes the semantics of is a subclass of. Now it is not up to an application to interpret is a subclass of instead its intended meaning must be used by all RDF processing software. By making such semantic definitions RDFS is a (still limited) language for defining the semantics of particular domains. Stated another way, RDF Schema is a primitive ontology language.In RDFS, properties are defined globally, that is, they are not encapsulated as attributes in class definitions. It is possible to define new properties that apply to an existing class without changing thatclass.Exampleofahierarchyofclasses

  • 1.3 Property Hierarchies The property rdfs:subPropertyOfis an instance of rdf:Property that is used to state that all resources related by one property are also related by another. For example, is taught by is a subproperty of involves. If a course c is taught by an academic staff member a, then c also involves a. The converse is not necessarily true. For example, a may be the convener of thecourse,oratutorwhomarksstudenthomeworkbutdoesnotteachc.PisasubpropertyofQ,ifQ(x,y)istruewheneverP(x,y)istrue.

    1.4 RDF versus RDFS Layers WeillustratethedifferentlayersinvolvedinRDFandRDFSusingasimpleexample:ConsidertheRDFstatementDiscreteMathematicsistaughtbyDavidBillingtonThe schema for this statement may contain classes, such as lecturers, academic staff members, staff members, and properties such as is taught by, involves, phone, employee id Next figure illustrates the layers of RDF and RDF Schema (blocks are properties, ellipses above the dashed lineareclasses,andellipsesbelowthedashedlineareinstances)The schema of the figure is itself written in a formal language, RDF Schema, that can express its ingredients:subClass,Property,subProperty,Resource,andsoon.

  • 2. RDF Schema: The Language The modeling primitives of RDF Schema are defined using resources and properties (RDF itself is used!). RDF allows one to express any statement about any resource, and that anything with a URI can be a resource. So, if we wish to say that the class lecturer is a subclass of academicstaffmember,wemay1.definetherequiredresourcesforlecturer,academicStaffMember,andsubClassOf2.definesubClassOftobeaproperty3.writethetriple(lecturer,subClassOf,academicStaffMember).All these steps are within the capabilities of RDF. So, an RDFS document (that is, an RDF schema)isjustanRDFdocument,andweusetheXMLbasedsyntaxofRDF.

    2.1 Core Classes Thecoreclassesarerdfs:Resource,theclassofallresourcesrdfs:Class,theclassofallclassesrdfs:Literal,theclassofallliterals(strings)

  • rdf:Property,theclassofallpropertiesrdf:Statement,theclassofallreifiedstatementsForexample,aclasslecturercanbedefinedasfollows:

    2.2 Core Properties for Defining Relationships Thecorepropertiesfordefiningrelationshipsarerdf:type,whichrelatesaresourcetoitsclass.rdfs:subClassOf,whichrelatesaclasstooneofitssuperclasses.Allinstancesofaclassareinstancesofitssuperclass.Aclassmaybeasubclassofmorethanoneclass.Asanexample,theclassfemaleProfessormaybeasubclassofbothfemaleandprofessor.rdfs:subPropertyOf,whichrelatesapropertytooneofitssuperproperties.Example:

    rdfs:subClassOfandrdfs:subPropertyOfaretransitive,bydefinition.rdfs:Classisasubclassofrdfs:Resource(everyclassisaresource)rdfs:Resource is an instance of rdfs:Class (rdfs:Resource is the class of all resources,soitisaclass!).Forthesamereason,everyclassisaninstanceofrdfs:Class.

    2.3 Core Properties for Restricting Properties Thecorepropertiesforrestrictingpropertiesarerdfs:domain, which specifies the domain of a property P and states that any resource that hasagivenpropertyisaninstanceofthedomainclasses.rdfs:range, which specifies the range of a property P and states that the values of a property areinstancesoftherangeclasses.Here is an example stating that whenever any resource has a phone number, it is (by inference) astaffmemberandthatitsvalueisaliteral:

  • 2.4 Useful Properties for Reification rdf:subject,whichrelatesareifiedstatementtoitssubjectrdf:predicate,whichrelatesareifiedstatementtoitspredicaterdf:object,whichrelatesareifiedstatementtoitsobject

    2.5 Container Classes rdf:Bag,theclassofbags,rdf:Seq,theclassofsequences,rdf:Alt,theclassofalternatives,rdfs:Container,asuperclassofallcontainerclasses,includingthethreeprecedingones.

    2.6 Utility Properties rdfs:seeAlsorelatesaresourcetoanotherresourcethatexplainsit.rdfs:isDefinedByis a subproperty of rdfs:seeAlso and relates a resource to the place whereitsdefinition,typicallyanRDFschema,isfound.rdfs:comment.Comments,typicallylongertext,canbeassociatedwitharesource.rdfs:label. A humanfriendly label (name) is associated with a resource. Among other purposes,itmayserveasthenameofanodeinagraphicrepresentationoftheRDFdocument.

    2.7 Example: A University TheclassoflecturersAlllecturersareacademicstaffmembers.Theclassofacademicstaffmembers

  • TheclassofstaffmembersTheclassofcoursesItrelatesonlycoursestolecturers.Inheritsitsdomain("course")andrange("lecturer")fromitssuperproperty"involves"Itisapropertyofstaffmembersandtakesliteralsasvalues.

    2.8 Example: Motor Vehicles

  • 3. RDF and RDF Schema in RDF Schema

    3.1 RDF

  • xmlns:rdf="http://www.w3.org/1999/02/22rdfsyntaxns#"xmlns:rdfs="http://www.w3.org/2000/01/rdfschema#">

    3.2 RDF Schema

  • The namespaces do not provide the full definition of RDF and RDF Schema. Consider, for example, rdfs:subClassOf. The namespace specifies only that it applies to classes and has a class as a value. The meaning of being a subclass, namely, that all instances of one class are also instances of its superclass, is not expressed anywhere. In fact, it cannot be expressed in an RDFdocument.Ifitcould,therewouldbenoneedfordefiningRDFSchema.

    4. RDF Serialization Formats While the data model that RDF uses is very simple, the serialized representation tends to get complicated when an RDF graph is saved to a file or sent over a network because of the various methods used to compact the data while still leaving it readable. These compaction mechanisms generally take the form of shortcuts that identify multiple references to a graph node using a shared but complex structure. Well be covering four serialization formats: NTriples, the simplest of notations N3, a compaction of the NTriple format RDF/XML, one of the most frequently used serialization formats and finally, RDF in attributes (known as RDFa), which canbeembeddedinotherserializationformatssuchasXHTML.

    4.1 A Graph of Friends

  • In order to compare the different serialization formats, we will build a simple graph that we can use throughout the examples to observe how the various serializations fold relationships together. For this example graph, well model a small part of Tobys social spherein particular, how he knows the other authors of his book. This will include things like the home page of his blog, his email address, his interests, and any other names he might use. These clues about Tobys identity are important to help differentiate our Toby from the numerous other Tobys in theworldandobtainastrongidentifier(URI)thatwecanuseforfutureinteraction.The relationships expressed in these social graphs have settled into a collection of wellknown predicates, forming a vocabulary of expression known as Friend of a Friend or simply FOAF. While FOAF deals primarily with people, the formal definition of FOAF states that the foaf:depictionpredicate can be used for graphics portraying any resource (or thing) in the world.TobysFOAFgraph

  • 4.2 N-Triples NTriples is a format for storing and transmitting data. It is a linebased, plain text serialisation format for RDF (Resource Description Framework) graphs, and a subset of the Turtle (Terse RDF Triple Language) format. NTriples was designed to be easier for software to parse and generate. ThereisverylittlevariationinhowanRDFgraphcanberepresentedinNTriples. NTriple notation is a very simple but verbose serialization that makes the NTriple format useful when handcrafting datasets for application testing and debugging. Each line of output in NTriple format represents a single statement containing a subject, predicate, and object followed by a dot. Except for blank nodes and literals, subjects, predicates, and objects are expressed as absolute URIs enclosed in angle brackets. Subjects and objects representing anonymous nodes are represented as _:name, where name is an alphanumeric node name that starts with a letter. Object literals are doublequoted strings that use the backslash to escape doublequotes, tabs, newlines, and the backslash character itself. String literals in NTriple notation can optionally specify their language when followed by @lang, where lang is an ISO 639 language code. Literals can also provide information about their datatype when followed by ^^type, where type is commonly an XSD (XML Schema Definition) datatype. The extension .nt is typically used when NTriples are stored in a file, and when they are transmitted over HTTP, the mimetypetext/plainisused.OurFOAFgraphcanberepresentedinNTripleformatas:. "kiwitobes". "TobySegaran".... _:jamie.._:jamie"JamieTaylor"._:jamie.

  • _:jamie. "ColinEvans"..."SemanticProgramming".

    4.3 N3 Notation3, or N3 as it is more commonly known, is a shorthand nonXML serialization of Resource Description Framework models, designed with humanreadability in mind: N3 is much more compact and readable than XML RDF notation. N3 has several features that go beyond a serializationforRDFmodels,suchassupportforRDFbasedrules.

    In an RDF graph, every connection between nodes represents a triple. Since each node may participate in a large number of relationships, we could significantly reduce the number of characters used in NTriples if we used a short symbol to represent repeated nodes. We could go further, recognizing that many of the URIs used in a specific model frequently come from related URIs. In much the same way that XML provides a namespace mechanism for generating short Qualified Name (qnames) for nodes, N3 allows us to define a URI prefix and identify entity URIsrelativetoasetofprefixesdeclaredatthebeginningofthedocument.N3 reduces this repetition by allowing you to combine multiple statements about the same subject by using a semicolon () after the first statement, so you only need to state the predicate andobjectforotherstatementsusingthesamesubject.Example:ThisRDFmodelinstandardXMLnotation

  • TonyBennWikipedia maybewritteninNotation3likethis:

    @prefixdc:.dc:title"TonyBenn"dc:publisher"Wikipedia".

    4.4 RDF/XML RDF/XML is a syntax,[1] defined by the W3C[2] , to express (i.e. serialize) an RDF graph as an XML document. RDF/XML is sometimes misleading called simply RDF because it was introduced among the other W3C specifications defining RDF and it was historically the first W3C standard RDF serialization format. Although the RDF/XML format is still in use, other RDF serializations are now preferred by many RDF users, both because they are more humanfriendly,[3] and because some RDF graphs are not representable in RDF/XML due to restrictionsonthesyntaxofXMLQNames.Conceptually, RDF/XML is built up from a series of smaller descriptions, each of which traces a path through an RDF graph. These paths are described in terms of the nodes (subjects) and the links(predicates)thatconnectthemtoothernodes(objects).AstripefromTobysFOAFgraph

  • If there is more than one path described in an RDF/XML document, all the descriptions must be children of a single RDF element if there is only one path described, the rdf:RDF element may beomitted.TheFOAFgraphwerepresentedinNTriplesandN3cannowberepresentedinRDF/XMLas:TobySegarankiwitobesSemanticProgrammingColinEvansJamieTaylor

    4.5 RDFa RDFa (or Resource Description Framework in Attributes[1]) is a W3C Recommendation that adds a set of attributelevel extensions to HTML, XHTML and various XMLbased document types for embedding rich metadata within Web documents. The RDF datamodel mapping

  • enables its use for embedding RDF subjectpredicateobject expressions within XHTML documents.ItalsoenablestheextractionofRDFmodeltriplesbycompliantuseragents.

    The essence of RDFa is to provide a set of attributes that can be used to carry metadata in an

    XMLlanguage(hencethe'a'inRDFa).

    Theseattributesare:

    aboutaURIorCURIEspecifyingtheresourcethemetadataisabout

    rel and rev specifying a relationship and reverserelationship with another

    resource,respectively

    src,hrefandresourcespecifyingthepartnerresource

    property specifying a property for the content of an element or the partner

    resource

    content optional attribute that overrides the content of the element when using the

    propertyattribute

    datatype optional attribute that specifies the datatype of text specified for use with

    thepropertyattribute

    typeof optional attribute that specifies the RDF type(s) of the subject or the partner

    resource(theresourcethatthemetadataisabout).

    Historically, RDFa 1.0 [rdfasyntax] was specified only for XHTML. RDFa 1.1 [rdfacore] is the newer version and the one used in this document. RDFa 1.1 is specified for both XHTML [xhtmlrdfa] and HTML5 [htmlrdfa]. In fact, RDFa 1.1 also works for any XMLbased languages like SVG [svg11]. This document uses HTML in all of the examples for simplicity, we use the term"HTML"throughoutthisdocumenttorefertoalloftheHTMLfamilylanguages.

    Validation RDFa is based on attributes. While some of the HTML attributes (e.g., href, src) have been reused, other RDFa attributes are new. This is important because some of the (X)HTML validators may not properly validate the HTML code until they are updated to recognize the new RDFa attributes. This is rarely a problem in practice since browsers simply ignore attributes that they do not recognize. None of the RDFaspecific attributes have any effect on the visual display of the HTML content. Authors do not have to worry about pages marked up with RDFa looking anydifferenttoahumanbeingfrompagesnotmarkedupwithRDFa.

    Resources: ASemanticWebPrimer,secondeditionGrigorisAntoniouandFrankvanHarmelen,2008ProgrammingtheSemanticWebbyTobySegaran,ColinEvans,andJamieTaylor,2009

  • http://eapps.software.ucv.ro/ss15wiki/images/a/a6/Antoniou.pdf3.43.6http://eapps.software.ucv.ro/ss15wiki/images/a/ac/Segaran.pdfRDFSerializationFormats6880http://www.cs.helsinki.fi/u/puustjar/soa15/SOC_RDF%20_OWL.pdfhttp://www.w3schools.com/webservices/ws_rdf_schema.asphttp://www.obitko.com/tutorials/ontologiessemanticweb/rdfschemardfs.htmlhttp://www.w3schools.com/webservices/ws_rdf_schema.asphttp://www.w3.org/TR/rdfschema/#ch_introductionhttp://en.wikipedia.org/wiki/Notation3http://en.wikipedia.org/wiki/RDF/XMLhttp://en.wikipedia.org/wiki/RDFa#cite_noterdfa_wiki2http://www.w3.org/TR/rdfaprimer/