Resource Description Framework
You can service enable data stored in a RDF (Resource Description Framework). First, follow the steps from 1 to 3 in creating a data service using various data sources. When you get to the Add New Data Source screen, select RDF as the data source type. The RDF-specific options will now be available for editing as shown below.
In the above example, 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.
To write a sample query to this datasource, see Sample 4: Querying a RDF datasource or read everything about query writing in Writing Data Service Queries.
Exposing relational data in RDF format
You can also expose relational data in RDF format by configuring the relevant data service query. For example, let's see how to expose a CSV datasource as a RDF resource.
- Create and deploy a data service using a CSV datasource. For information, see CSV.Â
- In the management console, click List under Services to open the Deployed Services page.
- Select the service created earlier using a CSV datasource to go to its dashboard.
- In the CSV data service's dashboard, click Edit Data Service.
  - Navigate to the Queries page and click Add New Query.  Â
Since the output is a RDF resul set, select output type as RDF from the drop-down list in the Output Mapping section.
RDF Base URI has the format rdf:about, 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#
To generate the response in RDF format, click Add New Output Mapping. There are two mapping types in RDF Output mapping.
- as an element
- as a resource
When mapping an element as a resource, give the resource URI along with the column name that needs to be mapped in curly brackets as shown below. This way, you can link two RDF resources together and create a relationship.
Save your changes and click Next to add resources. To create the RDF resource, map your RDF query as a resource in the data service.
Provide a suitable name and description to your resource. In this example, the resource method is Get . Select the the rdfQuery created in the previous step as the Query ID and Finish.
- You can access this RDF resource via a rest call and validate generated RDF response using an online validator such as: http://www.w3.org/RDF/Validator.