![]() |
Open Services for Lifecycle Collaboration
|
This Version
Latest Version AuthorsTable of Contents
This document provides details on how to form and serve RDF/XML, XML, Turtle, JSON and Atom representations of OSLC defined resources.
Recall from the OSLC Core specification section on OSLC Defined Resource Representations that "OSLC services SHOULD provide and accept RDF/XML representations for each OSLC resource." An RDF/XML representation SHOULD be:
application/rdf+xml
application/rdf+xml
OSLC resources are defined using the RDF data model and so, the first guidance for both parsing and generating RDF/XML representations is to use an RDF/XML toolkit. Follow the RDF/XML specifications and your toolkit's documentation. There are such toolkits available for most popular languages.
See separate page OSLC Core Spec RDF XML Examples
In this section we offer instructions for creating an XML representation for OSLC Defined Resources. The resultant XML representations are designed to validate as RDF/XML and therefore are often referred to as "constrained RDF/XML" or "abbreviated RDF/XML" representations, however the main intent of these instructions is to document a specific XML representation format for use in scenarios where a more unfettered RDF/XML representation or use of RDF/XML toolkits is not appropriate or preferred. OSLC domain specifications SHOULD refer to these instructions when requiring application/xml representations.
XML representations returned by OSLC Defined Resources SHOULD be:
application/xml
application/xml
This set of steps MAY be followed to form an XML representation of an OSLC Defined Resource. Other techniques MAY be used as long as the resulting XML is the same.
<rdf:RDF>
and include all required namespace declarations
rdf:about
attribute set to the URI of the resource
<oslc:ResponseInfo>
oslc:ResponseInfo
resource (using the property rules below) oslc:nextPage
property-value MUST point to the next page.
</oslc:ResponseInfo>
</rdf:RDF>
These are the property rules referred to above. OSLC property values are represented as XML elements with QNames formed using the Property's QName namespace prefix and name.
rdf:resource
attribute set to URI
rdf:ID
with an ID, unique to the resource and that will be referenced from a separate annotations element (see below).
rdf:nodeID
attribute set to local ID of the resource referred to
rdf:about
attribute set to URI of resource
rdf:nodeID
set to the local ID you wish to assign to the resource.
If there are any Anchors (see step 1.3.2 above) then for each:
rdf:Description
element with an rdf:about
that refers to the anchor's ID. rdf:Description
element
The examples on the OSLC Core Spec RDF XML Examples were generated using the rules above.
An OSLC Service MAY provide and understand JSON representations of OSLC Defined Resources and these representations SHOULD:
application/json
application/json
The first round of OSLC specifications defined a simple JSON format for representing OSLC resources and until there is a standard JSON representation for RDF data, we expect that OSLC domain specifications will continue to use this simple format.
The Core workgroup has some minor changes to the format to allow prefixes to be declared and offers guidance in the form of step-by-step instructions on how to generate it.
This set of steps MAY be followed to form a JSON representation of an OSLC Defined Resource. Other techniques MAY be used as long as the resulting JSON is the same.
rdf:about
set to the URI of the resource.
rdf:type
A resource can have multiple types, so this is a JSON Array of objects, each with an rdf:resource
field that is a type of the resource.
prefixes
set to a JSON object with one field per prefix used in the file, the field value should be the prefix base that corresponds to the prefix.
oslc:responseInfo
with value-type oslc:ResponseInfo
oslc:nextPage
property-value MUST point to the next page.
These are the property rules referred to above. For each property:
rdf:resource
set to URI of resource
rdf:nodeID
set to local ID of resource
rdf:about
set to URI of resource whose values are being inlined
rdf:nodeID
set to local ID you wish to assign to this resource. Only needed when Local Resource needs to refer to this resource.
See separate page OSLC Core Spec JSON Examples
An OSLC Service MAY provide and understand Turtle representations of OSLC Defined Resources.
application/x-turtle
application/x-turtle
As with RDF/XML we recommend using an RDF toolkit to parse and generate Turtle. Turtle is simple enough that we do not need to offer step-by-step guidance on how to generate it.
See separate page OSLC Core Spec Turtle Examples
An OSLC Service MAY provide and accept Atom Syndication Format representations of OSLC Defined Resources (reference: Atom Format).
Note that there are special steps below for creating an OSLC Query Resource representation in Atom format.
When a client requests an Atom representation of an OSLC Defined Resource and specifies via HTTP Accept header content-type application/atom+xml
or application/atom+xml;type=entry
then an OSLC Service SHOULD respond with an Atom representation.
To represent an OSLC Defined Resource in Atom format we use an Atom <entry>
element as document root, we map some OSLC properties to Atom elements and inside the Atom <content>
element, we place an RDF/XML representation (as defined above) of the resource that we are representing. Atom representations MUST comply with the rules of Atom Syndication Format (reference: Atom format).
<entry>
element <id>
element. Atom requires a unique ID here and in the form of a URN, the resource URI MAY be used here.
<title>
element. Atom requires a non-empty title value. A dcterms:title
value MAY be used here.
<updated>
element. Atom requires an updated date-time value. In cases where an updated-time value is difficult or expensive to compute, OSLC domain specifications might wish to declare this value to be insignificant.
<content>
element. Atom representations SHOULD provide a content element that contains an RDF/XML representation of the resource being represented.
<author>
element. Atom requires an author element.
<entry>
element
When a client requests an Atom representation of an OSLC query resource and specifies via HTTP Accept header content-type application/atom+xml
or then an OSLC Service SHOULD respond with an Atom feed representation as described below.
This representation guidance below represents each query result within the Atom feed as an Atom <entry>
with RDF/XML data inlined inside the Atom entry's <content>
element. Unless otherwise specified by the relevant OSLC domain specification, clients SHOULD expect that this inlined content will be full and unconstrained RDF/XML.
To represent an OSLC Query Resource in Atom format we use an Atom <feed>
element as document root, add the required properties and then represent each member property value returned in the query response as an Atom <entry>
element.
<feed>
element atom:id
Must be a unique URN. The query resource URI may be used.
atom:title
With same value as the query's oslc:ResponseInfo
value for dcterms:title
atom:updated
Set to time that query result was generated
atom:author
This element is not meaningful but Atom requires it, so provide only a dummy value.
atom:summary
Set to oslc:ResponseInfo
value for dcterms:description
atom:link
With rel="self" set to same value as the query's resource URI
atom:link
With rel="next" set to same value as the query's oslc:ResponseInfo
value for oslc:nextPage
<entry>
element
atom:id
Must be a unique URN. The member value's URI may be used.
atom:title
If the member value has a dcterms:title
value, then use that. Otherwise provide a non-empty string with only a dummy value.
atom:updated
If the member value has a dcterms:modified
value then use that. Otherwise use same value used at feed level.
atom:author
If the member value provides dcterms:creator
values, then each should be represented as an atom:author
element.
atom:content
element. atom:content
element's src
attribute to the URI of the member value
atom:content
element's type
attribute to application/rdf+xml
rdf:about
attribute of the root element to the URI of the query result.
</entry>
element
</feed>
element
See separate page OSLC Core Spec Atom Examples