360 likes | 495 Views
Other RDF Capabilities. Exercise: Write the following information into a set of statements (triples) and then draw them into and RDF graph
E N D
Exercise: Write the following information into a set of statements (triples) and then draw them into and RDF graph • The article on giant squids, titled "Architeuthis Dux," at http://burningbird.net/articles/monsters3.htm, written by Shelley Powers, explores the giant's squid's mythological representation as the legendary Kraken as well as describing current efforts to capture images of a live specimen. In addition, the article also provides descriptions of a giant squid's physical characteristics. It is part of a four-part series, described at http://burningbird.net/articles/monsters.htm and entitled "A Tale of Two Monsters."
The article is uniquely identified by its URI, http://burningbird.net/articles/monsters3.htm. • The article was written by Shelley Powers—predicate is written by, value is Shelley Powers. • The article's title is "Architeuthis Dux"—predicate is title, value is Architeuthis Dux. • The article is one of a four-part series—predicate is series member, value is http://burningbird.net/articles/monsters.htm. • The series is titled "A Tale of Two Monsters"—series predicate is title, value is A Tale of Two Monsters. • The article associates the giant squid with the legendary Kraken—predicate is associates, value is Kraken and giant squid. • The article provides physical descriptions of the giant squid—predicate is provides, value is physical description of giant squid.
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:pstcn="http://burningbird.net/postcon/elements/1.0/"> <rdf:Descriptionrdf:about="http://burningbird.net/articles/monsters3.htm"> <pstcn:author>Shelley Powers</pstcn:author> <pstcn:title>Architeuthis Dux</pstcn:title> <pstcn:seriesrdf:resource="http://burningbird.net/articles/monsters.htm" /> <pstcn:contains>Physical description of giant squids</pstcn:contains> <pstcn:alsoContains>Tale of the Legendary Kraken</pstcn:alsoContains> </rdf:Description> <rdf:Descriptionrdf:about="http://burningbird.net/articles/monsters.htm"> <pstcn:seriesTitle>A Tale of Two Monsters</pstcn:seriesTitle> </rdf:Description> </rdf:RDF>
Another representation Nesting one resource description in another shows the connection between the two more clearly <?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:pstcn="http://burningbird.net/postcon/elements/1.0/"> <rdf:Description rdf:about="http://burningbird.net/articles/monsters3.htm"> <pstcn:author>Shelley Powers</pstcn:author> <pstcn:title>Architeuthis Dux</pstcn:title> <pstcn:series> <rdf:Description rdf:about= "http://burningbird.net/articles/monsters.htm"> <pstcn:SeriesTitle>A Tale of Two Monsters</pstcn:SeriesTitle> </rdf:Description> </pstcn:series> <pstcn:contains>Physical description of giant squids</pstcn:contains> <pstcn:alsoContains>Tale of the Legendary Kraken</pstcn:alsoContains> </rdf:Description> </rdf:RDF>
RDF Vocabulary • A Resource Description Foundation (RDF) vocabulary is a defined set of predicates that can be used in an application • XML representation of RDF
1. <?xml version="1.0"?> 2. <rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 3. xmlns:exterms="http://www.example.org/terms/"> 4. <rdf:Descriptionrdf:about="http://www.example.org/index.html"> 5. <exterms:creation-date>August 16, 1999</exterms:creation-date> 6. </rdf:Description> 7. </rdf:RDF> Line 1, <?xml version="1.0"?>, is the XML declaration, which indicates that the following content is XML, and what version of XML it is Line 2 begins an rdf:RDFelement. This indicates that the following XML content (starting here and ending with the </rdf:RDF> in line 7) is intended to represent RDF. Line 3 specifies another XML namespace declaration, this time for the prefix exterms: Lines 4-6 provide the RDF/XML for the specific statement
RDF/XML for Two Statements 1. <?xml version="1.0"?> 2. <rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 3. xmlns:dc="http://purl.org/dc/elements/1.1/" 4. xmlns:exterms="http://www.example.org/terms/"> 5. <rdf:Descriptionrdf:about="http://www.example.org/index.html"> 6. <exterms:creation-date>August 16, 1999</exterms:creation-date> 7. </rdf:Description> 8. <rdf:Descriptionrdf:about="http://www.example.org/index.html"> 9. <dc:language>en</dc:language> 10. </rdf:Description> 11. </rdf:RDF>
Several Statements About the Same Resource 1. <?xml version="1.0"?> 2. <rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 3. xmlns:dc="http://purl.org/dc/elements/1.1/" 4. xmlns:exterms="http://www.example.org/terms/"> 5. <rdf:Descriptionrdf:about="http://www.example.org/index.html"> 6. <exterms:creation-date>August 16, 1999</exterms:creation-date> 7. <dc:language>en</dc:language> 8. <dc:creatorrdf:resource="http://www.example.org/staffid/85740"/> 9. </rdf:Description> 10. </rdf:RDF>
a graph saying "the document 'http://www.w3.org/TR/rdf-syntax-grammar' has a title 'RDF/XML Syntax Specification (Revised)' and has an editor, the editor has a name 'Dave Beckett' and a home page 'http://purl.org/net/dajobe/' "
RDF/XML Describing a Blank Node 1. <?xml version="1.0"?> 2. <rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 3. xmlns:dc="http://purl.org/dc/elements/1.1/" 4. xmlns:exterms="http://example.org/stuff/1.0/"> 5. <rdf:Descriptionrdf:about="http://www.w3.org/TR/rdf-syntax-grammar"> 6. <dc:title>RDF/XML Syntax Specification (Revised)</dc:title> 7. <exterms:editorrdf:nodeID="abc"/> 8. </rdf:Description> 9. <rdf:Descriptionrdf:nodeID="abc"> 10. <exterms:fullName>Dave Beckett</exterms:fullName> 11. <exterms:homePagerdf:resource="http://purl.org/net/dajobe/"/> 12. </rdf:Description> 13. </rdf:RDF>
RDF/XML Using a Typed Literal 1. <?xml version="1.0"?> 2. <rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 3. xmlns:exterms="http://www.example.org/terms/"> 4. <rdf:Descriptionrdf:about="http://www.example.org/index.html"> 5. <exterms:creation-date rdf:datatype= "http://www.w3.org/2001/XMLSchema#date">1999-08-16 </exterms:creation-date> 6. </rdf:Description> 7. </rdf:RDF>
RDF/XML for example.com's Catalog 1. <?xml version="1.0"?> 2. <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> 3. <rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 4. xmlns:exterms="http://www.example.com/terms/"> 5. <rdf:Descriptionrdf:ID="item10245"> 6. <exterms:modelrdf:datatype="&xsd;string">Overnighter</exterms:model> 7. <exterms:sleepsrdf:datatype="&xsd;integer">2</exterms:sleeps> 8. <exterms:weightrdf:datatype="&xsd;decimal">2.4</exterms:weight> 9. <exterms:packedSizerdf:datatype="&xsd;integer">784</exterms:packedSize> 10. </rdf:Description> ...other product descriptions... 11. </rdf:RDF> An important difference from previous examples is that, in line 5, the rdf:Description element has an rdf:ID attribute instead of an rdf:about attribute
1. <?xml version="1.0"?> 2. <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> 3. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 4. xmlns:sportex="http://www.exampleRatings.com/terms/"> 5. <rdf:Description rdf:about="http://www.example.com/2002/04/products#item10245"> 6. <sportex:ratingBy rdf:datatype="&xsd;string">Richard Roe</sportex:ratingBy> 7. <sportex:numberStars rdf:datatype="&xsd;integer">5</sportex:numberStars> 8. </rdf:Description> 9. </rdf:RDF> giving the absolute URIref http://www.example.com/2002/04/products#item10245. line 5 uses an rdf:Description element with an rdf:about attribute whose value is the full URIref of the tent. The use of this URIref allows the tent being referred to in the rating to be precisely identified.
1. <?xml version="1.0"?> 2. <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> 3. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 4. xmlns:exterms="http://www.example.com/terms/" 5. xml:base="http://www.example.com/2002/04/products"> 6. <rdf:Description rdf:ID="item10245"> 7. <rdf:type rdf:resource="http://www.example.com/terms/Tent"/> 8. <exterms:model rdf:datatype="&xsd;string">Overnighter</exterms:model> 9. <exterms:sleeps rdf:datatype="&xsd;integer">2</exterms:sleeps> 10. <exterms:weight rdf:datatype="&xsd;decimal">2.4</exterms:weight> 11. <exterms:packedSize rdf:datatype="&xsd;integer">784</exterms:packedSize> 12. </rdf:Description> ...other product descriptions... 13. </rdf:RDF> the rdf:type property in line 7 indicates that the resource being described is an instance of the class identified by the URIref http://www.example.com/terms/Tent
RDF graph describing Joe Smith <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns="http://www.example.org/~joe/contact.rdf#"> <foaf:Personrdf:about= "http://www.example.org/~joe/contact.rdf#joesmith"> <foaf:mboxrdf:resource="mailto:joe.smith@example.org"/> <foaf:homepage rdf:resource="http://www.example.org/~joe/"/> <foaf:family_name>Smith</foaf:family_name> <foaf:givenname>Joe</foaf:givenname> </foaf:Person> </rdf:RDF> The RDF language namespace prefix is usually rdf:
RDF vocabulary includes… rdf:type- it is a predicate used to state that a resource is an instance of a class rdf:XMLLiteral - the class of typed literals (i.e., of XML literal values) rdf:Property - the class of properties (i.e. binary relations that are used as predicates in triples) rdf:Alt, rdf:Bag, rdf:Seq- containers of alternatives, unordered containers, and ordered containers (see figure with bag for an example) rdf:List - the class of RDF Lists rdf:nil - an instance of rdf:List representing the empty list rdf:Statement, rdf:subject, rdf:predicate, rdf:object - used for reification
A Bag (a resource having type rdf:Bag) represents a group of resources or literals, possibly including duplicate members, where there is no significance in the order of the members. For example, a Bag might be used to describe a group of part numbers in which the order of entry or processing of the part numbers does not matter.
<?xml version="1.0"?> <rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:s="http://example.org/students/vocab#"> <rdf:Descriptionrdf:about="http://example.org/courses/6.001"> <s:students> <rdf:Bag> <rdf:lirdf:resource="http://example.org/students/Amy"/> <rdf:lirdf:resource="http://example.org/students/Mohamed"/> <rdf:lirdf:resource="http://example.org/students/Johann"/> <rdf:lirdf:resource="http://example.org/students/Maria"/> <rdf:lirdf:resource="http://example.org/students/Phuong"/> </rdf:Bag> </s:students> </rdf:Description> </rdf:RDF>
An Alternative or Alt (a resource having type rdf:Alt) represents a group of resources or literals that are alternatives (typically for a single value of a property). For example, an Alt might be used to describe alternative language translations for the title of a book, or to describe a list of alternative Internet sites at which a resource might be found. An application using a property whose value is an Alt container should be aware that it can choose any one of the members of the group as appropriate.
RDF/XML for an Alt Container <?xml version="1.0"?> <rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:s="http://example.org/packages/vocab#"> <rdf:Descriptionrdf:about="http://example.org/packages/X11"> <s:DistributionSite> <rdf:Alt> <rdf:lirdf:resource="ftp://ftp.example.org"/> <rdf:lirdf:resource="ftp://ftp1.example.org"/> <rdf:lirdf:resource="ftp://ftp2.example.org"/> </rdf:Alt> </s:DistributionSite> </rdf:Description> </rdf:RDF>
A Sequence or Seq (a resource having type rdf:Seq) represents a group of resources or literals, possibly including duplicate members, where the order of the members is significant. For example, a Sequence might be used to describe a group that must be maintained in alphabetical order.
RDF Collections • A limitation of the containers described is that there is no way to close them, i.e., to say "these are all the members of the container“ • a container only says that certain identified resources are members; it does not say that other members do not exist. • Also, while one graph may describe some of the members, there is no way to exclude the possibility that there is another graph somewhere that describes additional members.
RDF Collections • RDF provides support for describing groups containing only the specified members, in the form of RDF collections • An RDF collection is a group of things represented as a list structure in the RDF graph. This list structure is constructed using a predefined collection vocabulary consisting of the • predefined type rdf:List, • the predefined properties rdf:first and • rdf:rest, and • the predefined resource rdf:nil.
RDF Collections <?xml version="1.0"?> <rdf:RDFxmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:s="http://example.org/students/vocab#"> <rdf:Descriptionrdf:about="http://example.org/courses/6.001"> <s:students rdf:parseType="Collection"> <rdf:Descriptionrdf:about="http://example.org/students/Amy"/> <rdf:Descriptionrdf:about="http://example.org/students/Mohamed"/> <rdf:Descriptionrdf:about="http://example.org/students/Johann"/> </s:students> </rdf:Description> </rdf:RDF>
RDF Reification • RDF reification allows to disassemble a statement (triple) to its parts and to use the whole statement or parts of the statement as a part of other triples • The whole triple can then be treated as a resource which allows to make assertions about the statement • :john :has :cat [ a rdf:Statement; rdf:subject :john; rdf:predicate :has; rdf:object :cat ] the result is resource that can for example participate as a subject in another triple
<?xml version="1.0"?> <!DOCTYPE rdf:RDF [<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#">]> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:exterms="http://www.example.com/terms/" xml:base="http://www.example.com/2002/04/products"> <rdf:Description rdf:ID="item10245"> <exterms:weight rdf:datatype="&xsd;decimal">2.4</exterms:weight> </rdf:Description> <rdf:Statement rdf:about="#triple12345"> <rdf:subject rdf:resource="http://www.example.com/2002/04/products#item10245"/> <rdf:predicate rdf:resource="http://www.example.com/terms/weight"/> <rdf:object rdf:datatype="&xsd;decimal">2.4</rdf:object> <dc:creator rdf:resource="http://www.example.com/staffid/85740"/> </rdf:Statement> </rdf:RDF> RDF/XML for the Reification Example
Assignment • Write a note on triplification of Wikipedia data in the form of dbpedia