rdf tutorial

沃侯林
2023-12-01

http://www710.univ-lyon1.fr/~champin/rdf-tutorial/

http://www.w3.org/TR/rdf-schema/

 

http://www.w3.org/TR/rdf-primer/

 

http://wiki.w3china.org/wiki/index.php/RDF%E5%85%A5%E9%97%A8_%E6%8E%A8%E8%8D%90%E6%A0%87%E5%87%86

 

 

PDF Primer:

(1)RDF is intended for situations in which this information needs to be processed by applications, rather than being only displayed to people. RDF provides a common framework for expressing this information so it can be exchanged between applications without loss of meaning.

(2) This enables RDF to represent simple statements about resources as a graph of nodes and arcs representing the resources, and their properties and values.、

(3)RDF provides a way to express simple statements about resources, using named properties and values. However, RDF user communities also need the ability to define the vocabularies  (terms) they intend to use in those statements, specifically,  to indicate that they are describing specific kinds or classes of resources, and will use specific properties in describing those resources.

(4)

Example 23 shows how this schema could be written in RDF/XML.

<?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:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xml:base="http://example.org/schemas/vehicles">

<rdf:Description rdf:ID="MotorVehicle">
  <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
</rdf:Description>

<rdf:Description rdf:ID="PassengerVehicle">
  <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
  <rdfs:subClassOf rdf:resource="#MotorVehicle"/>
</rdf:Description>

<rdf:Description rdf:ID="Truck">
  <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
  <rdfs:subClassOf rdf:resource="#MotorVehicle"/>
</rdf:Description>

<rdf:Description rdf:ID="Van">
  <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
  <rdfs:subClassOf rdf:resource="#MotorVehicle"/>
</rdf:Description>

<rdf:Description rdf:ID="MiniVan">
  <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
  <rdfs:subClassOf rdf:resource="#Van"/>
  <rdfs:subClassOf rdf:resource="#PassengerVehicle"/>
</rdf:Description>

</rdf:RDF>

As discussed in Section 3.2 in connection with Example 13 , RDF/XML provides an abbreviation for describing resources having an rdf:type property (typed nodes ). Since RDF Schema classes are RDF resources, this abbreviation can be applied to the description of classes. Using this abbreviation, the schema could also be described as shown in Example 24 :

<?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:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xml:base="http://example.org/schemas/vehicles">

<rdfs:Class rdf:ID="MotorVehicle"/>

<rdfs:Class rdf:ID="PassengerVehicle">
  <rdfs:subClassOf rdf:resource="#MotorVehicle"/>
</rdfs:Class>

<rdfs:Class rdf:ID="Truck">
  <rdfs:subClassOf rdf:resource="#MotorVehicle"/>
</rdfs:Class>

<rdfs:Class rdf:ID="Van">
  <rdfs:subClassOf rdf:resource="#MotorVehicle"/>
</rdfs:Class>

<rdfs:Class rdf:ID="MiniVan">
  <rdfs:subClassOf rdf:resource="#Van"/>
  <rdfs:subClassOf rdf:resource="#PassengerVehicle"/>
</rdfs:Class>

</rdf:RDF>

Similar typed node abbreviations will be used throughout the rest of this section.

The RDF/XML in Example 23 and Example 24 introduces names, such as MotorVehicle , for the resources (classes) that it describes using rdf:ID , to give the effect of "assigning" URIrefs relative to the schema document as described in Section 3.2 . rdf:ID is useful here because it both abbreviates the URIrefs, and also provides an additional check that the value of the rdf:ID attribute is unique against the current base URI (usually the document URI). This helps pick up repeated rdf:ID values when defining the names of classes and properties in RDF schemas. Relative URIrefs based on these names can then be used in other class definitions within the same schema (e.g., as #MotorVehicle is used in the description of the other classes). The full URIref of this class, assuming that the schema itself was the resource http://example.org/schemas/vehicles , would be http://example.org/schemas/vehicles#MotorVehicle (shown in Figure 18 ). As noted in Section 3.2 , to ensure that the references to these schema classes would be consistently maintained even if the schema were relocated or copied (or to simply assign a base URIref for the schema classes without assuming they are all published at a single location), the class descriptions could also include an explicit xml:base="http://example.org/schemas/vehicles" declaration. Use of an explicit xml:base declaration is considered good practice, and one is provided in both examples.

To refer to these classes in RDF instance data (e.g., data describing individual vehicles of these classes) located elsewhere, example.org would need to identify the classes either by writing absolute URIrefs, by using relative URIrefs together with an appropriate xml:base declaration, or by using QNames together with an appropriate namespace declaration that allows the QNames to be expanded to the proper URIrefs. For example, the resource exthings:companyCar could be described as an instance of the class ex:MotorVehicle described in the schema of Example 24 by the RDF/XML shown in Example 25 :

<?xml version="1.0"?>
<rdf:RDF   
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  
  xmlns:ex="http://example.org/schemas/vehicles#"
  xml:base="http://example.org/things">

   <ex:MotorVehicle rdf:ID="companyCar"/>

</rdf:RDF>

Note that the QName ex:MotorVehicle , when expanded using the namespace declaration xmlns:ex="http://example.org/schemas/vehicles#" , becomes the full URIref http://example.org/schemas/vehicles#MotorVehicle , which is the correct URIref for the MotorVehicle class as shown in Figure 18 . The xml:base declaration xml:base="http://example.org/things" is provided to allow the rdf:ID="companyCar" to expand to the proper exthings:companyCar URIref (since a QName cannot be used as the value of the rdf:ID attribute).

 

(5)to be continued

 

 类似资料:

相关阅读

相关文章

相关问答