Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

RDF Main Elements

RDF Main Elements


The main elements of RDF are and can represent a certain resource .


rdf:RDF Element

rdf:RDF is the root element of an RDF document. It defines an XML document as an RDF document. It also contains the reference to the RDF namespace:

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

  ...

Description goes here...


rdf:Description Element

rdf:Description element can identify a resource via the about attribute.

rdf:Description element can contain those elements that describe the resource:

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:cd="http://www.recshop.fake/cd#">

rdf:about="http://www.recshop.fake/cd/Empire Burlesque">

  cd:artistBob Dylan

  cd:countryUSA

  cd:companyColumbia

  cd:price10.90

  cd:year1985

The elements artist, country, company, price, and year are defined in the namespace http://www.recshop.fake/cd#. This namespace is outside RDF (not part of RDF). RDF only defines the framework. The elements artist, country, company, price, and year must be defined by others (companies, organizations, individuals, etc.).


property (property) to define an attribute (attribute)

Property elements can also be defined as attributes (instead of elements):

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:cd="http://www.recshop.fake/cd#">

rdf:about="http://www.recshop.fake/cd/Empire Burlesque"

cd:artist="Bob Dylan" cd:country="USA"

cd:company="Columbia" cd:price="10.90"

cd:year="1985" />


property (property) to define an attribute (attribute)

Property elements can also be defined as attributes (instead of elements):

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:cd="http://www.recshop.fake/cd#">

rdf:about="http://www.recshop.fake/cd/Empire Burlesque">

 

  ...

  ...

In the example above, the property artist has no value, but references a resource containing information about the artist.