300 likes | 476 Vues
Practical RDF Chapter 5. Important Concepts from the W3C RDF Vocabulary/Schema. Shelley Powers, O’Reilly SNU IDB Lab. Hyewon Kim. Outline. Introduction RDF Vocabulary: Describing the Data Core RDF Schema Elements Refining RDF Vocabularies with Constraints RDF Schema Alternatives.
E N D
Practical RDFChapter 5. Important Concepts from the W3C RDF Vocabulary/Schema Shelley Powers, O’Reilly SNU IDB Lab. Hyewon Kim
Outline • Introduction • RDF Vocabulary: Describing the Data • Core RDF Schema Elements • Refining RDF Vocabularies with Constraints • RDF Schema Alternatives
Introduction • RDF (Resource Description Framework) specification • Syntax specification • How RDF constructs relate to each other • How they can be diagrammed in XML • Schema specification • A ruled-based dictionary that defines the elements of importance to a domain • Describes how these elements relate to one another
RDF Vocabulary: Describing the Data • Metadata – data about data • Same specification can be used with many different domain • Concept of metadata’s role • Relational database • Store many different types of data by using metadata structures
RDF Vocabulary: Describing the Data Metadata’s Role in Existing Applications (1/3) • Example • Change the domain and the domain-specific storage constructs become pretty useless
RDF Vocabulary: Describing the Data Metadata’s Role in Existing Applications (2/3) • Multiple uses of the same storage mechanism for different domains • Relational database schema defines below • Database tables • Primary and foreign key • Columns • Provide a domain-neutral description of information Schema table Schema column
RDF Vocabulary: Describing the Data Metadata’s Role in Existing Applications (3/3) • Same syntax for web resource • Don’t store information about a web resource in a domain-specific XML element called WEB_PAGE • Store it on an rdf:Description element and use RDF to define the properties for this new resource
RDF Vocabulary: Describing the Data RDF Schema: Metadata Repository • RDF Schema • Provides the same functionality as the relational database schema • Provides the resources necessary to describe the objects and properties of a domain-specific schema • Vocabulary • It describes • Objects • Attributes • Relationships within a specific area of interest
Core RDF Schema Elements • RDF Schema elements • Marked by a specific namespace xmlns:rdfs = “http://www.w3c.org/2000/01/rdf-schema#”
Core RDF Schema ElementsOverview of the RDF Schema classes (1/6)
Core RDF Schema ElementsOverview of the RDF Schema classes (2/6) • rdfs:Resource & rdfs:Class • Every resource within an RDF document has a common ancestor class : rdf:resource • All new resource types are identified by an rdfs:Class statement, including the rdfs:Resource element itself <? Xml version=“1.0”?> <rdf:RDF xmlns:rdf=“http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:pstcn=“http://buringbird.net/postcon/elements/1.0”> <rdf:Descriptoinrdf:about=“http://burningbird.net/articles/monsters3.htm”> <pstcn:author>Shelley Powers></pstcn:author> <pstcn:title>Architeuthis Dux</pstcn:title> <rdf:Description> </rdf:RDF> Schema <rdfs:Classrdf:ID=“Article”> <rdfs:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource/”> </rdfs:Class>
Core RDF Schema ElementsOverview of the RDF Schema classes (3/6) • rdfs:Container • Superclass of all RDF container elements • rdf:Bag • rdf:Seg • rdf:Alt • rdfs:ContainerMembershipProperty • Resource is a member of a container • _1, _2, _3 and so on
Core RDF Schema ElementsOverview of the RDF Schema classes (4/6) • rdfs:Datatype • Class of all data types • Subclass of rdfs:Literal • rdfs:XMLLiteral • Allows to embed XML into the RDF/XML document • Subclass of rdfs:Literal • Instance of rdfs:Datatype • Class of all XML literals
Core RDF Schema ElementsOverview of the RDF Schema classes (5/6) • A few RDF classes • Cross the boundary between the metalanguage and instances of the same
Core RDF Schema ElementsOverview of the RDF Schema classes (6/6) • RDF Schema for Article <? Xml version=“1.0”?> <rdf:RDF xmlns:rdf=“http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:rdfs=“http://www.w3.org/2000/01/rdf-schema#” xmlns:pstcn=“http://buringbird.net/postcon/elements/1.0”> <rdfs:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/Article”> <rdfs:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource”/> </rdfs:Class> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/title”> <rdfs:domainrdf:resource=http://burningbird.net/postcon/elements/1.0/Article” /> </rdf:Property> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/author”> <rdfs:domainrdf:resource=http://burningbird.net/postcon/elements/1.0/Article” /> </rdf:Property> </rdf:RDF>
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (1/10) • Demonstrations of the RDF Schema Properties • Only difference between two • One is instance of business data (such as Article) • The other is metadata ( related to the RDF model)
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (2/10) • Core properties (from both the RDF and RDFS namespaces ) of RDF Schema
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (3/10) • rdfs:subClassOf • Identify a class that is a subclass of another <rdfs:Classrdf:ID=“WebPage”> rdfs:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource” /> </rdfs:Class> <rdfs:Classrdf:ID=“Article”> rdfs:subClassOfrdf:resource=“http://burningbird.net/schema#WebPage” /> </rdfs:Class>
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (4/10) • rdfs:subPropertyOf <? Xml version=“1.0”?> <rdf:RDF xmlns:rdf=“http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:rdfs=“http://www.w3.org/2000/01/rdf-schema#” xmlns:pstcn=“http://buringbird.net/postcon/elements/1.0”> <rdfs:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/Article”> <rdfs:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource”/> </rdfs:Class> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/title”> <rdfs:domainrdf:resource=http://burningbird.net/postcon/elements/1.0/Article” /> </rdf:Property> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/author”> <rdfs:domainrdf:resource=http://burningbird.net/postcon/elements/1.0/Article” /> </rdf:Property> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/primaryAuthor”> <rdfs:domainrdf:resource=“http://burningbird.net/postcon/elements/1.0/Article” /> <rdfs:subPropertyOfrdf:resource=“http://burningbird.net/postcon/elements/1.0/author” /> </rdf:Property> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/secondaryAuthor”> <rdfs:domainrdf:resource=“http://burningbird.net/postcon/elements/1.0/Article” /> <rdfs:subPropertyOfrdf:resource=“http://burningbird.net/postcon/elements/1.0/author” /> </rdf:Property>/rdf:RDF>
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (5/10) • rdfs:seeAlso • Another resource contains additional information <rdfs:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/Article/History” > <rdfs:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource” /> </rdfs:Class> <rdfs:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/Article” > <rdfs:subClassOfrdf:resource=http://www.w3.org/2000/01/rdf-schema#Resource” /> <rdfs:seeAlsordf:resource=“http://burningbird.net/postcon/elements/1.0/Article/History” /> </rdfs:Class>
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (6/10) • rdfs:isDefinedBy • Identify the namespace for the resource <rdfs:Classrdf:about="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement” > <rdfs:isDefinedByrdf:resource=“http://www.w3.org/1999/02/22-rdf-syntax-ns” /> <rdfs:labelxml:lang=“en”>Statement</rdfs:label> <rdfs:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource” /> <rdfs:comment>The class of RDF statement.</rdfs:comment> </rdfs:Class> <rdfs:Classrdf:about="http://www.w3.org/2000/01/rdf-schema#Literal” > <rdfs:isDefinedByrdf:resource=“http://www.w3.org/2000/01/rdf-schema#” /> <rdfs:labelxml:lang=“en”>Literal</rdfs:label> <rdfs:comment>This represents the set of atomic values, eg. Textual string</rdfs:comment> </rdfs:Class>
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (7/10) • rdfs:member • Superproperty for each numbered container element • _1, _2, and so on • rdfs:comment • Provide human readability to an RDF model • Provide documentation of resources • rdfs:label • Provide a readable version of the resource’s name • Can attach xml:lang
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (8/10) • RDF Schema documentation elements <? xml version=“1.0”?> <rdf:RDF xmlns:rdf=“http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:rdfs=“http://www.w3.org/2000/01/rdf-schema#” xmlns:pstcn=“http://buringbird.net/postcon/elements/1.0”> <rdfs:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/Article”> <rdfs:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource”/> <rdfs:comment>Unique Online article</rdfs:comment> <rdfs:labelxml:lang=“en”>Article</rdfs:label> </rdfs:Class> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/title”> <rdf:typerdf:resource=“http://www.w3.org/2000/01/rdf-schema#Prpoerty” /> <rdfs:domainrdf:resource=“http://burningbird.net/postcon/elements/1.0/Article” /> <rdfs:comment>Online Article Title</rdfs:comment> <rdfs:labelxml:lang=“en”>Article</rdfs:label> </rdf:Property> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/author”> <rdf:typerdf:resource=“http://www.w3.org/2000/01/rdf-schema#Prpoerty” /> <rdfs:domainrdf:resource=“http://burningbird.net/postcon/elements/1.0/Article” /> <rdfs:comment>Primary author of article</rdfs:comment> <rdfs:labelxml:lang=“en”>Author</rdfs:label> </rdf:Property> </rdf:RDF>
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (9/10) • rdf:type • Define the type of resources • Usually assumed and is not explicitly given <rdfs:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/author” > <rdfs:domainrdf:resource=http://burningbird.net/postcon/elements/1.0/Article” /> <rdfs:comment>Primary author of article</rdfs:comment> <rdfs:labelxml:lang=“en”>Author</rdfs:label> <rdf:typerdf:resource=“http://www.w3.org/1999/02/22-rdf-schema#Property” /> </rdfs:Property>
Core RDF Schema ElementsDemonstrations of the RDF Schema Properties (10/10) • rdf:subject, rdf:predicate, rdf:object • Used with reification to explicitly define an RDF statement • rdf:first, rdf:rest • Explicitly define the relationships within a collection
Refining RDF Vocabularies with Constraints (1/2) • rdfs:domain • Associate a property with the resource • An RDF property can be used for more than one resource type <? Xml version=“1.0”?> <rdf:RDF xmlns:rdf=“http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:rdfs=“http://www.w3.org/2000/01/rdf-schema#” xmlns:pstcn=“http://buringbird.net/postcon/elements/1.0”> <rdfs:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/Article”> <rdfs:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource”/> <rdfs:comment>Unique Online article</rdfs:comment> <rdfs:labelxml:lang=“en”>Article</rdfs:label> </rdfs:Class> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/title”> <rdf:typerdf:resource=http://www.w3.org/2000/01/rdf-schema#Prpoerty /> <rdfs:domainrdf:resource=“http://burningbird.net/postcon/elements/1.0/Article” /> <rdfs:comment>Online Article Title</rdfs:comment> <rdfs:labelxml:lang=“en”>Article</rdfs:label> </rdf:Property> <rdf:Propertyrdf:about=“http://burningbird.net/postcon/elements/1.0/author”> <rdf:typerdf:resource=http://www.w3.org/2000/01/rdf-schema#Prpoerty /> <rdfs:domainrdf:resource=“http://burningbird.net/postcon/elements/1.0/Article” /> <rdfs:comment>Primary author of article</rdfs:comment> <rdfs:labelxml:lang=“en”>Author</rdfs:label> </rdf:Property> </rdf:RDF>
Refining RDF Vocabularies with Constraints (2/2) • rdfs:range • Only one RDF range constraint can be attached to any property • Can use a master class for a property (more than one data type) <? Xml version=“1.0”?> <rdf:RDF xmlns:rdf=“http://www.w3.org/1999/02/22-rdf-syntax-ns#” xmlns:rdfs=“http://www.w3.org/2000/01/rdf-schema#” xmlns:pstcn=“http://buringbird.net/postcon/elements/1.0”> <rdfs:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/WebPage”> <rdfs:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource”/> </rdfs:Class> <rdf:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/Article”> <rdf:subClassOfrdf:resource=“http://burningbird.net/postcon/elements/1.0/WebPage” /> </rdf:Class> <rdf:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/Example”> <rdf:subClassOfrdf:resource=“http://burningbird.net/postcon/elements/1.0/WebPage” /> </rdf:Class> <rdf:Classrdf:about=“http://burningbird.net/postcon/elements/1.0/Directory”> <rdf:subClassOfrdf:resource=“http://www.w3.org/2000/01/rdf-schema#Resource” /> </rdf:Class> <rdf:Propertyrdf:about=“http://buringbird.net/postcon/elements/1.0/contains”> <rdf:domainrdf:resource=“http://burningbird.net/postcon/elements/1.0/Directory” /> <rdf:rangerdf:resource=http://burningbird.net/postcon/elements/1.0/WebPage” /> </rdf:Property> </rdf:RDF> domain range Directory WebPage Article Example
RDF Schema Alternatives (1/3) • DTD(Document Type Declarations) & XML Schema <!ELEMENT Items(item*) <!ELEMENT item(productName, quantity, USPrice, comment? shipDate?)> <!ATTLIST item partNum CDATA #REQUIRED> <!ELEMENT productName (#PCDATA)> <!ELEMENT quantity (#PCDATA)> <!ELEMENT USPrice(#PCDATA)> <!ELEMENT comment(#PCDATA)> <!ELEMENT shipDate(#PCDATA)>
RDF Schema Alternatives (2/3) • DTD(Document Type Declarations) & XML Schema <xsd:element name=“Items”> <xsd:complexType name=“items”> <xsd:sequence> <xsd:element name=“item” minOccurs=“0” maxOccurs=“unbounded”> <xsd:complexType> <xsd:sequence> <xsd:element name=“productName” type=“xsd:string”/> <xsd:element name=“quantity”> <simpleType> <xsd:restriction base=“xsd:positiveInteger”> <xsd:maxExclusive value=“100”/> <xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name=“USPrice” type=“xsd:decimal”/> <xsd:element name=“comment” minOccurs=“0”/> <xsd:element name=“shipDate” type=“xsd:date” minOccurs=“0”/> </xsd:sequence> <xsd:attribute name=“partNum” type=“SKU” use=“required” /> </complexType> </xsd:element> </xsd:sequence> </xsd:complxType> </xsd:element>
RDF Schema Alternatives (3/3) • RELAX NG Compact Syntax • Combination of DTD readability and W3C XML Schema data typing Items = element Items {item*} Item = element item {att.partNum, productName, quantity, USPrice, comment?, shipDate? } att.partNum = attribute partNum {text} productName = element productName {text} Quantity = element quantity {xsd:positiveInteger {maxExclusive=“100”}} USPrice = element USPrice {xsd:decimal} Comment = element comment {text} shipDate = element shipDate {xsd:date} Start = Items