Study Notes of Basic Semantic Web tutorial (2)

Source: Internet
Author: User
Ii. RDF Overview (see http://zh.transwiki.org/cn/rdfprimer.htm)
1. ontology:
An ontology is an explicit formal specification of a conceptual system (conceptualization.
Generally, an ontology depicts a domain. A typical ontology consists of a limited number of terms and their relationships.
★In the world wide web environment, ontology provides a consensus for a given field. This consensus is necessary to eliminate terminology differences.
By ing the differences in terms to a direct ing between a common ontology, these terms can be eliminated.
No matter which solution is used, the ontology supports semantic interoperability ).
2. Imagine two applications that want to communicate through the same vocabulary. To achieve this goal, it is necessary to define all element names and attribute names that may be used. At the same time, we also need to define the structure of the document: What values can be used for an attribute and what elements can appear in other elements.
3. RDF
RDF is the basic data model in the semantic network framework. It includes three object types: resource, property, and statement.
Resources: all objects that can be expressed in RDF are called resources, including all information on the network, virtual concepts, and real things. A resource is identified by a unique URI. Different resources have different Uris.
Attribute: describes the features (attributes) of a resource or the relationship between resources.

Statement: describes the attributes of a resource. A statement consists of three parts, which are generally referred to as the triples <subject, attribute, Object> of RDF. The subject is a described resource, represented by Uri. The object represents the value of the subject in attributes. It can be another resource (represented by Uri) or text (literal ).

4. XML-based RDF syntax
Example 1: Describe the RDF/XML of the web page creation date
(1) <? XML version = "1.0"?>
(2) <RDF: RDF xmlns: RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns"
(3) xmlns: External = "http://www.example.org/terms/">

(4) <RDF: Description RDF: About = "http://www.example.org/index.html">
(5) <exterms: Creation-date> August 16,199 9 </exterms: Creation-date>
(6) </RDF: Description>

(7) </RDF: RDF>

(Adding a row number is just to facilitate the interpretation of examples. The RDF/XML does not contain a row number)
It seems that a lot of overhead is a bit confusing. considering each part of the XML in turn will help you understand its role.
The first line is the XML Declaration (XML declaration): <? XML version = "1.0"?>. It indicates that the following content is XML and the XML version is 1.0.
Row 3 starts with an RDF: RDF element. It indicates that the following XML content (from here until 7th rows </RDF: RDF>) is used to express RDF. The same row is followed by the RDF: the XML namespace Declaration (XML namespace Declaration), that is, the xmlns attribute of the first tag of the RDF. This statement indicates that all the tags with the prefix of "RDF" appear in the current content belong to the namespace identified by the following uriref:
Http://www.w3.org/5o/02/22-rdf-syntax-ns.pdf #. Take Effect.
Row 3rd is another XML namespace Declaration (about the prefix exterms ). This statement is represented by another xmlns attribute of the RDF: RDF element. It specifies the prefix exterms: With the namespace uriref
Http://www.example.org/terms/. Urirefsstarted at http://www.example.org/terms/is used by example.org.
Example] terms in the defined vocabulary. The ">" symbol at the end of the row 3rd indicates the end of the first tag of RDF. Lines 1st to 3 are common and essential parts to indicate that the current content is RDF/XML and
Namespace used.
Line 4-6 is the main part of the statement in Fig. When talking about the RDF statement, it is obvious that the statement is a "Description )". In addition, it is a description of the subject (in this example, it is about http://www.example.org/index.html ). This is exactly how the statement is represented in RDF/XML. In row 4th, the start tag of the RDF: description indicates the beginning of a resource description, and then identifies the resource (that is, the subject of the statement) stated as "about (). RDF/XML uses the RDF: About attribute to specify the uriref of the subject resource.
Row 5th uses QNAME exterms: Creation-date as the tag and provides "property element" to represent the predicate and object of the statement. Select QNAME)
Exterms: Creation-date. You can extend the local Name Creation-date to http://www.example.org/terms/creation-date, which is a property element) the content is the object of the statement-that is, the ordinary text "August 19,199 9" (the value of the creation-date attribute of the subject resource ). Property elements exist in the nested form in the content contained in the RDF: Description element. This means that the property is applied to the RDF: About attribute of the RDF: Description element) the specified resource. Row 6th indicates that the RDF: Description ends here.
Finally, row 7th indicates the end of the RDF: RDF element starting from row 2nd. When the XML content can be determined as RDF/XML through context, the content of the RDF/XML can be included without the use of the RDF: RDF element.

Example 2: Describe the two statements in RDF/XML

1. <? XML version = "1.0"?>
2. <RDF: RDF xmlns: 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: Description RDF: About = "http://www.example.org/index.html">
6. <exterms: Creation-date> August 16,199 9 </exterms: Creation-date>
7. </RDF: Description>
8. <RDF: Description RDF: About = "http://www.example.org/index.html">
9. <DC: Language> en </DC: Language>
10. </RDF: Description>
11. </RDF: RDF>
Example 2 is the same as Example 1. It only adds an RDF: Description element (8th to 10 rows) that expresses the second statement ). (Row 3rd provides another namespace declaration to identify the namespace used in the second statement.
). You can add any number of statements in the same way. You only need to use an RDF: Description element for each statement. As shown in Example 3, once the XML and namespace Declaration are completed

The writing of RDF statements is simple and clear.

Example 3: briefly express multiple attributes
1. <? XML version = "1.0"?>

2. <RDF: RDF xmlns: 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: Description RDF: About = "http://www.example.org/index.html">
6. <exterms: Creation-date> August 16,199 9 </exterms: Creation-date>
7. <DC: Language> en </DC: Language>
8. <DC: Creator RDF: Resource = "http://www.example.org/staffid/85740"/>
9. </RDF: Description>

10. </RDF: RDF>
Compared with the previous two examples, in Example 3, a DC is added: The Creator property element (in Row 3) [annotation/property element) indicates the property in RDF) XML element]. In addition, the three attribute elements (representing the three attributes of the subject http://www.example.org/index.html) are embedded in the same RDF: Description element (marking the subject http://www.example.org/index.html), rather than writing an individual RDF: Description element for each statement.

Row 8th introduces a new form of attribute elements. The DC: Language element in line 1 is similar to the exterms: Creation-date element in example 2. They all use plain literal to represent the attribute value, the preceding text is enclosed by the START-tag and end-tag corresponding to the property name. However, the DC: Creator element in Row 1 indicates that one property value is an attribute of another resource (rather than plain text. If you write the uriref of the resource as plain text (like the first two elements) enclosed in the first and last tags, this indicates that the value of the DC: Creator element is a string http://www.example.org/staffid/85740, instead of the resource identified by the uriref represented by this string. To demonstrate this difference, the DC: Creator element is written in the form of an empty element tag (that is, there is no tail tag) and uses an RDF: Resource attribute) to express the property value ). RDF: The resource attribute indicates that the value of the property element is another resource identified by uriref ). Because the uriref is used as the attribute value
Uriref must be written in the form of absolute uriref or relative uriref, rather than QNAME as the element name or attribute name.

Use a separate statement to write the following example:
<? 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: exterms = "http://www.example.org/terms/">


<RDF: Description RDF: About = "http://www.example.org/index.html">
<Exterms: Creation-date> August 16,199 9 </exterms: Creation-date>
</RDF: Description>


<RDF: Description RDF: About = "http://www.example.org/index.html">
<DC: Language> en </DC: Language>
</RDF: Description>


<RDF: Description RDF: About = "http://www.example.org/index.html">
<DC: Creator RDF: Resource = "http://www.example.org/staffid/85740"/>
</RDF: Description>


</RDF: RDF>


RDF/XML can also represent a graph containing a blank node (that is, a node without uriref). For details, see section 2.3. For example, figure 13 (taken from a [RDF-SYNTAX]) shows a diagram that expresses the following information:
"The document 'HTTP: // www.w3.org/tr/rdf-syntax-grammar' has a title (title) ('rdf/XML syntax specification (revised) ') and an editor (editor), while the editor's name (name) for 'Dave bucket' and home page (home page), it is 'HTTP: // purl.org/net/dajobe /'".
Example 4: Describe the blank node's RDF/XML

1. <? XML version = "1.0"?>


2. <RDF: RDF xmlns: 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: Description RDF: About = "http://www.w3.org/TR/rdf-syntax-grammar">
6. <DC: title> RDF/XML syntax specification (revised) </DC: title>
7. <exterms: Editor RDF: nodeid = "ABC"/>
8. </RDF: Description>


9. <RDF: Description RDF: nodeid = "ABC">
10. <exterms: fullname> Dave Beckett </exterms: fullname>
11. <exterms: homepage RDF: Resource = "http://purl.org/net/dajobe/"/>
12. </RDF: Description>


13. </RDF: RDF>


In Example 4, row 9th uses the blank node identifier ABC to identify the blank node of the subject that serves as multiple statements, then, use the blank node identifier in row 7th to indicate that the blank node corresponding to it is a resource.
Exterms: Editor property ). Compared to other methods described in [RDF-SYNTAX], the advantage of using a blank node identifier is that the same blank node can be referenced multiple times in an RDF/XML document.

Replace the statement in the preceding example with the type text instead of the ordinary text as the value of the exterms: Creation-date attribute (property values ).
Example 5: Use the RDF/XML
1. <? XML version = "1.0"?>
2. <RDF: RDF xmlns: RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns"
3. xmlns: exterms = "http://www.example.org/terms/">
 
4. <RDF: Description RDF: About = "http://www.example.org/index.html">
5. <exterms: Creation-date RDF: datatype =
"Http://www.w3.org/2001/XMLSchema#date">
</Exterms: Creation-date>
6. </RDF: Description>

7. </RDF: RDF>

In Example 5, the value of the exterms: Creation-date attribute element (property element) given in row 5th is a type of text (rather than a plain text), which is indicated by exterms: add an RDF: ype attribute to the Start-tag of the creation-date element and specify the data type. RDF: the value of the datatype attribute should be a uriref of a data type. In this example, it is a uriref of the date data type in XML schema. As an attribute value, uriref must be written in [//, that is, relative uriref or absolute uriref] instead of the QNAME format XSD: date as in the triple. Use a correct data type text as the element content. In this example, the text is August 16, 1999, which is a text that represents in XML schema.

An example shows that you need to write an RDF: ype attribute for each element whose value is a type text, and use a uriref that identifies a specific data type as the attribute value. As mentioned above, the urirefs used as attribute value must be completely written, rather than in the QNAME format. In this case, RDF/XML allows the use of XML entities to improve readability, which provides an additional shorthand form for urirefs. The essence of an XML Object declaration is to associate an XML name with a string. If the object name is referenced in the XML document, the XML processor replaces the reference with the corresponding string. For example, the following entity Declaration (written in the doctype declaration in the header of the RDF/XML document ):

<! Doctype RDF: RDF [<! Entity XSD "http://www.w3.org/2001/XMLSchema#">]>
Define the object XSD as a string that represents the namespace uriref (corresponding to the namespace of the XML schema data type. This statement allows the complete namespace uriref to be simply an object in the XML document.
Reference & XSD ;. In Example 5, use the preceding simple form to obtain Example 8.

Example 8: Use the type text and XML Entity's RDF/XML
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.org/terms/">

5. <RDF: Description RDF: About = "http://www.example.org/index.html">
6. <exterms: Creation-date RDF: datatype = "& XSD; Date">
</Exterms: Creation-date>
7. </RDF: Description>

8. </RDF: RDF>
The doctype declaration in row 2nd defines the object XSD, which is used in row 6th.
Although there are other simple forms for writing RDF/XML, the method described so far provides a simple and general method to express the RDF graph with RDF/XML. To apply these methods, an RDF graph can

In this way, write the RDF/xml:
? Blank node identifiers are specified for all blank nodes ).
? List each node in sequence and use it as the subject of a non-nested RDF: Description element (subject ). If the node has uriref, the RDF: Description element uses the RDF: About attribute.

(Attribute); If the node is a null node, the RDF: Description element uses the RDF: nodeid attribute ).
Create a correct property element for each triple that uses this node as the subject (subject ). This attribute element or element content is text (literal) (may be empty), or has an RDF: Resource attribute that specifies the object of the triple) (For objects with uriref), or an RDF: nodeid attribute that specifies the object of the triple (for objects with null nodes ).
5. a namespace defines a set of uriref for a specific purpose, called a vocabulary. In this way, we can use and share these results through such uriref.
6. Unlike typical programming languages and database systems, RDF does not have its own built-in data types, such as integer, real, complex, or date types. However, the RDF text provides a simple method for specifying the Data Type of a given text. The types used in the type text are defined externally and determined by their data type Uris.

Other RDF expressions
7. RDF container
Three types of containers
RDF: Bag (Package) unordered
RDF: seq (sequence) Order
RDF: ALT (replace)

8. RDF set
One disadvantage of a container is that it cannot be closed, that is, it cannot be said that these are all members of the container. A container only says that some identified resources are its Members, and it cannot be said that there are no other members. In addition, if

When a graph describes some of its Members, we cannot eliminate the possibility that a graph may also describe other members of the container elsewhere. In the form of a collection, RDF provides support for groups that describe specific members. An RDF set is a group of items expressed in the list structure. The list structure is represented by some predefined set vocabulary. The collection vocabulary of RDF includes attributes: RDF: First and RDF: rest, and resources.

RDF: nil.

9. Specific RDF
RDF provides a built-in vocabulary used to describe an RDF statement. The description of a statement using these words is called the reification of the statement ). The specific word collection of RDF contains the following types: RDF: Statement, attributes: RDF: subject, RDF: predicate, and RDF: object. However, exercise caution when using RDF to define words, because it is easy to think that these words define things that are not actually defined. This issue will be discussed later in this section.
Concrete is designed to express certain attributes, such as written date and RDF data metadata.

10. RDF Schema
RDF and RDFS are different from XML and XML schema.
RDF itself cannot define some classes and features for specific application requirements. These classes and features are called RDF words and must be defined by the RDF vocabulary Description Language: RDF Schema (an Extended Language of RDF. RDF Schema provides a type system for RDF. In some respects, the Type System of the RDF Schema type system is similar to the type system of the object-oriented programming language such as Java. For example, RDF Schema allows a resource to be defined as an instance of one or more classes. In addition, RDFS usually organizes classes into a hierarchical structure. For example, class ex: dog can be defined as a subclass of EX: mammal, while ex: mammal is a subclass of EX: animal. If a resource is an instance of the class ex: Dog, it implies that it is also an instance of the class ex: animal. However, the types and features of RDF are significantly different from those of programming languages in some aspects. There are not many ways to describe resources in the RDF class and feature, but some additional descriptions about the RDF resources are provided.
These capabilities of RDF Schema are also provided in the form of RDF vocabulary. That is to say, these RDF words are a set of pre-defined RDF resources with special meanings. The
Uri with the prefix http://www.w3.org/2000/01/rdf-schema# (QNAME usually uses the prefix RDFS :).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.