3.4 Representing Structured Data with rdf:valueNot all data relations in RDF represent straight binary connections between resource and object value. Some data values, such as measurement, have both a value and additional information that determines how you treat that value. In the following RDF/XML: <pstcn:lastEdited>18</pstcn:lastEdited> the statement is ambiguous because we don't know exactly what 18 means. Is it 18 days? Months? Hours? Did a person identified by the number 18 edit it? To represent more structured data, you can include the additional information directly in the value: <pstcn:lastEdited>18 days</pstcn:lastEdit>
However, this type of
<pstcn:lastEdited>18</pstcn:lastEdited> <pstcn:lastEditedUnit>day</pstcn:lastEditedUnit>
This works, but
Redefining the data would then result in:
<pstcn:lastEdited rdf:parseType="Resource">
<rdf:value>18</rdf:value>
<pstcn:lastEditedUnit>day</pstcn:lastEditedUnit>
</pstcn:lastEdited>
Now, not only do we know that we're dealing with structured data, we know what the actual value, the kernel of the data so to speak, is by the use of
rdf:value
. You could use your own predicate, but
rdf:value
is global in scope ”it crosses all RDF vocabularies ”making its use much more attractive if you're
|
3.5 The rdf:type PropertyOne general piece of information that is consistent about an RDF resource ”outside of the URI to uniquely identify it ”is the resource or class type. In the examples shown thus far, this value could implicitly be "Web Resource" to refer to all of the resources, or could be explicitly set to "article" for articles. All these would be correct, depending on how generically you want to define the resource and the other properties associated with the resource. To explicitly define the resource type, you would use the RDF rdf:type property.
Usually the
rdf:type
property is associated at the same level of granularity as the other properties. As the resources defined using RDF in this chapter all have properties associated more
In the
The value of the RDF
rdf:type
property is a URI identifying an
rdfs:Class
-typed resource (
rdfs:Class
is described in detail in Chapter 5). To
Example 3-13. Demonstrating the explicit resource property type
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:pstcn="http://burningbird.net/postcon/elements/1.0/">
<rdf:Description rdf:about="http://burningbird.net/articles/monsters3.htm">
<pstcn:Author>Shelley Powers</pstcn:Author>
<pstcn:Title>Architeuthis Dux</pstcn:Title>
<rdf:type rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" />
</rdf:Description>
</rdf:RDF>
The type property includes a resource reference for the schema element, in this case for the Article class.
Rather than
Within the shortcut, the type property is created directly as the element type rather than as a generic RDF Description element. This new syntax, demonstrated in Example 3-14, leads to correct interpretation of the RDF within an XML parser. Example 3-14. Abbreviated syntax version of type property
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:pstcn="http://burningbird.net/postcon/elements/1.0/">
<pstcn:Article rdf:about="http://burningbird.net/articles/monsters3.htm">
<pstcn:Author>Shelley Powers</pstcn:Author>
<pstcn:Title>Architeuthis Dux</pstcn:Title>
</pstcn:Article>
</rdf:RDF>
Notice the capitalization of the first letter for Article . This provides a hint that the element is a resource, rather than a predicate type.
This shortcut approach is particularly effective in ensuring that there is no doubt as to the nature of the resource being described,
Other RDF/XML shortcuts that can help cut through some of the rather
|