This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Exposing Relational Data in RDF Format

In this tutorial, we went through the process of exposing data stored in an RDF file using a data service. In the following instructions, we will look at how relational data can be exposed in RDF format by configuring the relevant data service query. For example, let's see how to expose a CSV datasource as an RDF resource.

Before you begin

Create and deploy a data service using a CSV datasource. See the tutorial on exposing CSV data as a data service for instructions.

Exposing relational data in RDF format

Follow the steps given below.

  1. In the management console, click List under Services to open the Deployed Services page.
  2. Select the service created earlier using a CSV datasource to go to its dashboard.
  3. In the CSV data service's dashboard, click Edit Data Service.
  4. Navigate to the Queries page and click Add New Query.    
  5. 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/{id}
    Row namespace : http://www.product/cd#

  6. 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.

  7. 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.

  8. 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.

  9. 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.