Main elements of RDF
- Previous Page RDF Examples
- Next Page RDF Containers
The main elements of RDF are <RDF> and the <Description> element that can represent a resource.
The <rdf:RDF> element
The <rdf:RDF> is the root element of an RDF document. It defines an XML document as an RDF document. It also includes references to the RDF namespace:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" . . Description goes here . </rdf:RDF>
The <rdf:Description> element
The <rdf:Description> element can identify a resource via the about attribute.
The <rdf:Description> element can contain elements that describe resources:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cd="http://www.recshop.fake/cd#"> <rdf:Description rdf:about="http://www.recshop.fake/cd/Empire Burlesque"> <cd:artist>Bob Dylan</cd:artist> <cd:country>USA</cd:country> <cd:company>Columbia</cd:company> <cd:price>10.90</cd:price> <cd:year>1985</cd:year> </rdf:Description> </rdf:RDF>
The elements artist, country, company, price, and year are defined in the namespace http://www.recshop.fake/cd#. This namespace is outside of RDF (not part of RDF). RDF only defines this framework. The elements artist, country, company, price, and year must be defined by others (companies, organizations, or individuals, etc.).
The term (property) is used to define an attribute (attribute).
Property elements (property elements) can also be defined as attributes (attributes) (replacing elements):
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cd="http://www.recshop.fake/cd#"> <rdf:Description 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" /> </rdf:RDF>
Property definition resource
Property elements (property elements) can also be defined as resources (resources):
In the above example, the attribute 'artist' does not have a value, but it references a resource that contains information about the artist.
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cd="http://www.recshop.fake/cd#"> <rdf:Description rdf:about="http://www.recshop.fake/cd/Empire Burlesque"> <cd:artist rdf:resource="http://www.recshop.fake/cd/dylan" /> . . . . </rdf:Description> </rdf:RDF>
- Previous Page RDF Examples
- Next Page RDF Containers