Top

2.10.3. Creating the Browser Application

Step 1 - Create the Visual Studio Project.

  1. Open

    Visual Studio

    and create a new

    ASP.NET Web Application

    called RDFWebApp.

    Figure 2.163. New Web Application

    New Web Application

  2. Create client side entities with datasvcutil.exe

    • Open a command prompt.

    • Navigate to *C:\WINDOWS\Microsoft.NET\Framework\v3.5*.

    • Generate the client classes using the following command:

      datasvcutil.exe /uri:http://example.com/WebDataService1.svc /out:DemoEntities.cs
      

      Note the address of the service - you may need to change the port number to match the one seen in the address at the end of Step 4 in Creating the Web Service.

  3. Add the classes to RDFWebApp.

    • Right click RDFWebApp

    • Choose to add an existing item and add c:\WINDOWS\Microsoft.NET\Framework\v3.5\DemoEntities.cs.

  4. Add a reference to System.Data.Services.Client to the project.

Step 2 - Display the contents of sparqlview as a table on the page

To display the RDF data on the web page we create a table with a row for each item in sparqlview. We then use each IRI from sparqlview to create a hyperlink. The hyperlinks are displayed in the table cells. To do this add the following block of code to the page_load method in Default.aspx.cs.

 DemoModel.DemoEntities svc = new DemoModel.DemoEntities(new Uri("http://example.com/WebDataService1.svc"));

  var query = svc.sparqlview;
  Table iriTable = new Table();
  this.Controls.Add(iriTable);

  foreach (DemoModel.sparqlview sv in query)
  {
      TableRow tRow = new TableRow();
      iriTable.Rows.Add(tRow);
      TableCell tCell = new TableCell();
      tRow.Cells.Add(tCell);
      HyperLink h = new HyperLink();
      h.Text = sv.s;
      h.NavigateUrl = sv.s;
      tCell.Controls.Add(h);
  }

Note the address of the service in the first line - you may need to change the port number to match the one seen in the address at the end of Step 4 in Creating the Web Service.

Compile and run RDFWebApp (ensuring that the service created above is still running). This will launch a browser and display the IRIs from sparqlview as a list of hyperlinks.

Figure 2.164. list of hyperlinks

list of hyperlinks

With the Cartridges VAD package installed in Virtuoso, clicking on these links will take you to a description page of the referenced resource. The description page is created using description.vsp .

Figure 2.165. Description page

Description page