[oslc-core] Meeting notes and using rdf:RDF as root element
Dave
snoopdave at gmail.com
Fri Jul 9 11:07:01 EDT 2010
On Thu, Jul 8, 2010 at 11:59 AM, Dave <snoopdave at gmail.com> wrote:
>> Furthermore, when I try to generate RDF using
>> the toolkit, it will not conform to the OSLC subset so I'll have to write
>> my own serializer. We are therefore in the paradoxical situation of
>> embracing RDF as our data model yet making life more difficult for
>> implementers that want to use RDF toolkits.
>
> This could be a real issue and probably warrants some testing with
> Jena and other RDF serializers. Can anybody comment in this issue?
To answer my own question...
Here's how you would generate OSLC recommended RDF with Jena using Java:
// define a bogus OSLC resource
Property oslcBogon = new
PropertyImpl("http://open-services.net/ns/bogus#Bogon");
// define a property
Property dctermsTitle = new PropertyImpl("http://purl.org/dc/terms/title");
// create a model, add the prefixes we want
Model model = ModelFactory.createDefaultModel();
model.setNsPrefix("dcterms", "http://purl.org/dc/terms/");
model.setNsPrefix("oslc-bogus", "http://open-services.net/ns/bogus#");
// create a resource, add a title
Resource resource = model.createResource("http://example.com/resources/1");
resource.addProperty(RDF.type, oslcBogon);
resource.addLiteral(dctermsTitle, "This is my title.");
// spit it out in OSLC form
RDFWriter writer = model.getWriter("RDF/XML-ABBREV");
String useAbsoluteURLs = null;
writer.write(model, System.out, useAbsoluteURLs);
When you run that you get this:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:oslc-bogus="http://open-services.net/ns/bogus#">
<oslc-bogus:Bogon rdf:about="http://example.com/resources/1">
<dcterms:title
rdf:datatype="http://www.w3.org/2001/XMLSchema#string">This is my
title.</dcterms:title>
</oslc-bogus:Bogon>
</rdf:RDF>
No special serializers is required.
Thanks,
- Dave
More information about the Oslc-Core
mailing list