I am using EasyRdf to create a few nodes in the graph. My problem is that I am trying to create a new blank node and also set an rdf:about
property to it that points to the correct resource.
$rdf = new EasyRdf_Graph();
$datapoint_resource = $rdf->newBNode(
'rdf:Description'
);
The problem with this code is that it creates a new rdf:Description
node but there's no way I can add rdf:about
as a property to it.
<rdf:Description>
<!-- Some resources here -->
</rdf:Description>
What I need is
<rdf:Description rdf:about="http://link.to/my/resource/id">
<!-- Some resources here -->
</rdf:Description>
I've tried adding rdf:about
as a resource but the W3C validator outputs the error "rdf:about is not allowed as an element tag here".
<rdf:Description>
<rdf:about rdf:resource="http://ordex.probook/rdf/datapoint/5813af3dbf552b25ed30fd5c9f1eea0b"/>
</rdf:Description>
So this doesn't work and it probably isn't a good idea either.
How can I add rdf:about
when creating a new blank node or what other things do you suggest?
rdf:about
is used in the RDF/XML serialization of an RDF graph to indicate the URI of a resource. Blank nodes, which you're creating with Graph.newBNode()
don't have URIs. To create a URI resource, you Graph.resource(uri). Thus, you should do this instead:
$datapoint_resource = $rdf->resource('http://link.to/my/resource/id');
For more about how rdf:about
is used; see the RDF 1.1 XML Syntax. It includes, for instance, this example:
The Figure 2 graph consists of some nodes that are IRIs (and others that are not) and this can be added to the RDF/XML using the rdf:about attribute on node elements to give the result in Example 2:
EXAMPLE 2 Node Elements with IRIs added
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar"> <ex:editor> <rdf:Description> <ex:homePage> <rdf:Description rdf:about="http://purl.org/net/dajobe/"> </rdf:Description> </ex:homePage> </rdf:Description> </ex:editor> </rdf:Description>