- a standard data model for the Semantic Web
1) data model: statements about resources in the form of S-P-O triples
2) Collection of RDF statements represents a labelled, directed graph
- a knowledge representation language
1) RDF is used as the foundation for the other knowledge representation and ontology languages on the Semantic Web
- a family of data formats and notations
1) RDF/XML: the normative (standard) syntax
2) RDF/N3 family: compact, human-friendly, non-XML syntax (N3, Turtle, Ntriple)
https://en.wikipedia.org/wiki/Resource_Description_Framework
https://www.w3.org/RDF/
https://jena.apache.org/tutorials/rdf_api.html
2. RDF Requirements
- A means for identifying objects and vocabulary terms (URIs)
1) URI: Uniform Resource Identifier
2) URIrefs: URI references are URIs with optional fragment identifiers
https://lists.w3.org/Archives/Public/www-rdf-comments/2002OctDec/0043.html
- A means for distinguishing between terms from different vocabularies (XML namespaces and qualified names)
1) RDF uses XML namespaces to refer to elements of domain vocabularies
2) Namespaces used to abbreviate URIrefs to qualified names (QNames)
- A means for serialising triples (XML)
3. RDF/XML
: an XML-based format for expressing a collection of RDF triples (an RDF graph)
https://www.w3.org/TR/rdf-syntax-grammar/
https://www.w3schools.com/xml/xml_rdf.asp
- The anatomy of an RDF/XML file
<?xml version="1.0" ?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1"
xmlns:ex="http://example.org/ontology#">
<rdf:Description rdf:about="http://www.example.org">
<dc:title>Example Inc.Homepage</dc:title>
<dc:creator rdf:resource="mailto:amy@example.org"/>
<dc:creator>
<rdf:Description rdf:about="mailto:john@example.org">
<ex:name>John Smith</ex:name>
</rdf:Description>
</dc:creator>
</rdf:Description>
<ex:Website rdf:about="http://www.example.org"/>
</rdf:RDF>
1) Resource-valued predicates use the rdf:resource attribute
2) can have multiple predicates within an rdf:Description element
3) class membership: an object's membership of a class is indicated using the rdf:type and can be replaced with QName of class
<rdf:Description rdf:about="http://www.example.org"> <rdf:type rdf:resource="http://example.org/ontology#Website"/> </rdf:Description> |
xmlns:ex="http://example.org/ontology#" <ex:Website rdf:about="http://www.example.org"/> |
4) the striped syntax: graph could be serialised using two rdf:Description elements and the second statement could be inserted within the predicate element of the first
<rdf:Description rdf:about="http://www.example.org"> <dc:creator rdf:resource="mailto:john@example.org"/> </rdf:Description> <rdf:Description rdf:about="mailto:john@example.org"> <ex:name>John Smith</ex:name> </rdf:Description> |
<rdf:Description rdf:about="http://www.example.org"> <dc:creator> <rdf:Description rdf:about="mailto:john@example.org"> <ex:name>John Smith</ex:name> </rdf:Description> </dc:creator> </rdf:Description> |
- Common RDF/XML idioms
1) XML entities are defined for the XML namespaces URI prefixes
<?xml version="1.0" ?>
<!DOCTYPE rdf:RDF [
<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY dc 'http://purl.org/dc/elements/1.1'>
<!ENTITY ex 'http://example.org/ontology#'>
]>
<rdf:RDF xmlns:rdf="&rdf;"
xmlns:dc="&dc;"
xmlns:ex="&ex;">
2) used to abbreviate long URIrefs in attribute values (because QNames can't be used there)
- Common RDF idioms
1) Assertions about the null URIref are about the RDF file itself
- Blank nodes (bNodes): a node in an RDF graph representing a resource for which a URI or literal is not given
1) the striped syntax simplifies the RDF/XML serialisation -> remove the rdf:about attribute
=> we don't know two nodes are same or different...
<rdf:Description rdf:about="http://www.example.org">
<dc:creator>
<rdf:Description>
<ex:name>John Smith</ex:name>
</rdf:Description>
</dc:creator>
</rdf:Description>
<rdf:Description rdf:about="http://test.example.org">
<dc:creator>
<rdf:Description>
<ex:name>John Smith</ex:name>
</rdf:Description>
</dc:creator>
</rdf:Description>
https://en.wikipedia.org/wiki/Blank_node
- Node IDs: identifiers which are local to a given serialisation of an RDF graph
1) ambiguities resulting from blank nodes are resolved by using node IDs
2) not guarantee to remain unchanged when an RDF file is parsed and serialised
<rdf:Description rdf:about="http://www.example.org">
<dc:creator rdf:nodeID="foo23" />
</rdf:Description>
<rdf:Description rdf:about="http://test.example.org">
<dc:creator rdf:nodeID="foo23" />
</rdf:Description>
<rdf:Description rdf:nodeID="foo23">
<ex:name>John Smith</ex:name>
</rdf:Description>
https://www.w3.org/wiki/NodeId
rdf:about
|
rdf:nodeID
|
to specify the subjects of triples | to declare a new URIref within a document |
- Datatypes: literal values presented so far are plain and do not have a type
=> RDF uses XML Schema datatypes
- Containers
1) RDF provides means for describing groups of objects
2) containers are mutable: a third party could add new members to a container
3) three types of container are available in RDF:
rdf:Bag (an unordered group), rdf:Seq (an ordered group), rdf:Alt (a group of alternative)
<rdf:Description rdf:about="http://www.example.org">
<ex:members>
<rdf:Bag>
<rdf:li rdf:resource="mailto:john@example.org"/>
<rdf:li rdf:resource="mailto:sally@example.org"/>
<rdf:li rdf:resource="mailto:bill@example.org"/>
</rdf:Bag>
</ex:members>
</rdf:Description>
- Collections
1) a different way of expressing ordered finite groups in RDF
2) collections are immutable: cannot be altered without rendering the collection ill-formed
3) similar to linked list
<rdf:Description rdf:about="http://www.example.org">
<ex:members rdf:parseType="Collection">
<rdf:Description rdf:about="mailto:john@example.org"/>
<rdf:Description rdf:about="mailto:sally@example.org"/>
<rdf:Description rdf:about="mailto:bill@example.org"/>
</ex:members>
</rdf:Description>
4. The RDF/N3 Family
- Ntriples, N3 and Turtle
1) Simpler syntaxes than RDF/XML
* Ntriples is the simplest (a subset of Turtle)
* N3 and Turtle are more concise
* Turtle is the standard version of N3
2) General syntax for a triple
* <subject> <predicate> <object> .
* Resources are indicated <like this>
* Literals are indicated "like this"
https://www.w3.org/2000/10/swap/Primer.html
- The anatomy of an Ntriples file
<http:www.sciam.com/> <http://purl.org/dc/elements/1.1/title> "Scientific American" .
- The anatomy of an Turtle/N3 file
1) ";" allows grouping of triples with common subject
<http:www.example.org>
<http://purl.org/dc/elements/1.1/creator> <mailto:john@example.org> ;
<http://purl.org/dc/elements/1.1/title> "Example Inc. Homepage" .
2) "," allows grouping of triples with common subject and predicate
<http:www.example.org>
<http://purl.org/dc/elements/1.1/creator> <mailto:john@example.org> , <mailto:amy@example.org>
- Common RDF/N3 idioms
1) @prefix used to introduce QName abbreviations to N3 and Turtle
@prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdf:<http://purl.org/dc/elements/1.1>
@prefix rdf:<http://example.org/ontology#>
<http://www.example.org> dc:creator <mailto:john@example.org> ;
rdf:type ex:Website .
2) @base used to introduce a base URI relative to which all URI fragment identifiers are expanded
@base <http:example.org/data>
@prefix foaf: <http://xmlns.com/foaf/0.1/>
<#john> foaf:name "John Smith"
- bNodes in N3 and Turtle
1) uses []
<http://www.example.org> dc:creator [ ex:name "John Smith" ] .
2) with nodeIDs
<http://www.example.org> dc:creator _:foo23 .
<http://test.example.org> dc:creator _:foo23 .
_:foo23 ex:name "John Smith" .
댓글 없음:
댓글 쓰기