Resource Description Framework
Follow the instructions below to create a data service using a RDF (Resource Description Framework) as the data source.
 1. Log on to the product's management console and select "Data Service -> Create" under the "Main" menu.
2. The Create Data Service page appears. Fill in the fields and click Next. The Data Service name is mandatory.
Info:
For more information on Advanced Configurations in creating data services, refer to section "Data Service Management -> Transaction Handling."
3. The Data Sources page appears. Click on the Add New Data Source link and add your Data Source details. Select the data source type as RDF.
For example,
Note:
We use a sample resource hosted online but you can also use one in your local machine. The RDF resource used in this example is hosted by NASA in this URL: http://nasa.dataincubator.org/~search.rdf?query=all
Click Save.
4. The added data source page appears. You can edit or delete the Data Source. To proceed click Next.
5. The Queries page appears.
Initially your service does not include any queries. Click 'Add New Query' to add a new query, input/output mappings, events etc. to your Data Service. Enter query details according to the structure of the response you want.
In this example, we have used the following SPARQL query to extract the specific aircraft information from the data source.
PREFIX space: <http://purl.org/net/schemas/space/> PREFIX relevance: <http://a9.com/-/opensearch/extensions/relevance/1.0/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT ?homepage ?name ?alternateName ?internationalDesignator ?mass ?score ?launch ?agency ?description WHERE { ?craft foaf:homepage ?homepage. ?craft foaf:name ?name. ?craft space:alternateName ?alternateName. ?craft space:internationalDesignator ?internationalDesignator. ?craft space:mass ?mass. ?craft relevance:score ?score. ?craft space:launch ?launch. ?craft space:agency ?agency. ?craft dc:description ?description. }
The input mapping section is used to specify parameters to the query. The above query extracts aircraft information according to the agency. Therefore, we take agency as an input parameter. Input parameters can be added by clicking Add Input Mappings.
We have also used the Grouped By Element Grouped By Element, Row Name and Row namespace.
Click on Add Output Mappings to map the response to an output XML. Once you have entered the output mapping details, click on Main Configuration and then the Save button.
The output mappings:
For information on adding validations to input mappings in the query, if any, refer to section Input Validators.
6. You have added one query to your data service configuration. You can edit or delete your query. To continue, click Next.
7. The Operations page appears. Click the Add new operation link to create an operation. Select a query to be executed when this operation is called.
Click Save once done. For example,
8. The Data Service configuration is done. Click Finish. (You can continue to add resources by clicking the Next button if you like)
9. You will be navigated to the "Deployed services" page.
From here, you can manage your data service. For instructions, refer to section "Service Management."
Exposing Relational Data in RDF Format
The data services feature supports exposing relational data in RDF (Resource Description Framework) format as a service. In the following example, we demonstrate how a CSV data source can be exposed as a RDF resource.
In order to expose relational data in RDF format, you need to configure the relevant data service query accordingly. To start, add a new query to your CSV data service. For instructions on creating a CSV data service, refer to section CSV.
1. Log on to the product's management console and select  "Services -> List" under the "Main" menu.
2. The Deployed Services page appears which lists out all the currently active services and service groups.
Click on the data service you want to edit.
3. The dashboard of the data service opens. Click on the Edit Data Service link. In this example, we edit using the management console.
4. Navigate to the Queries page of the data service and click the Add New Query link.
5. The Add New Query page opens.
Since the output is a RDF result set, select output type as RDF from the drop-down list in the Output Mapping section.
RDF Base URI contains the format of rdf:about URI which uniquely identifies each resource. In this example, the RDF base URI takes the value of column 1 of the CSV for each row and replaces it with the RDF about attribute inside rdf:Description element.
RDF Base URI : http://www.product/cd/{1} Row namespace : http://www.product/cd#
6. To generate the response in RDF format, click the Add New Output Mapping link. The Add/Edit Output Mapping window opens.
There are two mapping types in RDF Output mapping.
- as an element
- as a resource
When mapping an element as a resource, you need to give the resource URI along with the column name which needs to be mapped in curly brackets as shown below. This way we can link two RDF resources together and create a relationship between the two.
7. Once you create the output mappings, go back to the main configuration and save your RDF query.
8. Once the query is completed, navigate to the resources window by clicking Next.
In the Resources window, click Add New Resource.
9. To create the RDF resource, you need to map your RDF query as a resource in the data service.
Provide a suitable name and description for your resource. The resource method is Get. Select the the rdfQuery created in the previous step as the Query ID. Click Finish to deploy the data service.
Once we create the resource we can access our RDF resource via a rest call.
You can validate generated RDF response by using an Online validator such as: http://www.w3.org/RDF/Validator. For example: