HTML and CSS Reference
In-Depth Information
Now extend the previous example with another person and express a relationship between the two persons
(Listing 7-67)! The class of the entity can be declared by the typeof attribute. In this case, we use the Person class from
the FOAF vocabulary to “let the browser know” that John Smith is a person. The second person is declared exactly
the same way. Finally, we use the term knows from the FOAF vocabulary and pass it as the value of the rel attribute to
express that John Smith knows Peter Johnson (declared by the resource attribute).
Listing 7-67. Two People and the Relationship Between Them Expressed Using FOAF in RDFa
<body xmlns:foaf=" http://xmlns.com/foaf/0.1 " >
<p>
<span about="#john" typeof="foaf:Person" property="foaf:name" > John Smith </span> is
interested in smartphones. <span about="#jane" typeof="foaf:Person"
property="foaf:name" > Peter Johnson </span> is an Android developer. <span
about="#john" rel="foaf:knows" resource="#peter" > John and Peter knows each other.
</span>
</p>
</body>
Compare this machine-readable statement with MySQL database records displayed using PHP, and you have a
glimpse of the power of the Semantic Web!
Other vocabularies can be similarly used with RDFa. For example, Dublin Core metadata can be embedded to
the markup using RDFa, as shown in Listing 7-68.
Listing 7-68. An RDFa Annotation Using DC
<p xmlns:dc=" http://purl.org/dc/elements/1.1/ "
about="#standardweb" property="dc:title">
Web standardista <span about="#sikos" property="dc:creator">Dr. Sikos</span> describes
web standardization, accessibility, and web semantics in the second edition of
<cite about="#webstandards" property="dc:title">Web Standards</cite>. The first blog
post has been published on <span about="#webstandards" property="dc:date"
content="2014-10-11">11 October 2014</span>.
</p>
Microformats vs. Microdata vs. RDFa
You should have noticed that there are similar concepts defined by certain microformats and HTML5 microdata to
describe people, events, or licenses. RDFa, on the other hand, is not limited to such concepts and can be used to
annotate any kind of resource.
As discussed earlier, microformats reuse HTML attributes (for example, class , title ) and have separate
vocabularies that are difficult to combine, because microformats do not use the namespace mechanism. Last but not
least, microformats do not define an RDF representation. 7
HTML5 microdata, as also presented earlier, provides new attributes for HTML5 markup. HTML5 microdata is
easy to write and works well in documents that use a single external vocabulary. Combining different vocabularies
is rather complex in HTML5 microdata. Some vocabulary mappings, such as that of Dublin Core elements, are
supported by the technology by default. A missing feature is the concept of data types and namespaces. Fortunately,
however, HTML5 microdata defines a generic mapping to RDF, so it can be used to express triples.
7 It is possible to transform microformats to RDF using technologies such as XSLT and GRDDL, but such transformations depend
on the vocabularies being used.
 
Search WWH ::




Custom Search