Forms for SWOOP

Motivation

To provides a form interface for SWOOP to create instances with datatype and object properties. Without a form interface, when an ontology engineer wants to create an instance, he needs to create the instance first and add each datatype and object property one by one. It is inconvenient to create a large number of instances in this way. To provide convenience for instance creation, SWOOP provides a form interface so that the ontology engineer can fill up the datatype and object properties necessary for the instance and create them together with the instance.

Overview

The form is created as an annotea annotation for a class, so that the form can be used by anyone who is able to view the ontology. The form is a HTML form and a Javascript (Javascript 1.5 is supported) can be attached to the form. The developer of the form creates input entry for each datatype or object property necessary for the instance creation.

The developer of the form can write Javascript code to validate the data entered by the users. The function verify() returns true if the data is valid, otherwise it should return false. The developer of the form generates triples to create instances and properties. The function generateN3() creates a list of triples and assigns them to variables n3_x (x is the index starting from 0). The SWOOP creates instances and property assertions based on the triples generated by the Javascript.

How to use the form

HTML and Javascript Sample

<html>
  <head>
    
  </head>
  <body>
    <javascript code="
	var errorMessage;
	var numberOfN3;
	var terrorBase;

	function verify(){
	  if (name.length == 0){
	    errorMessage = 'the name of terrorist organization cannot be empty';
	    return false;
	  } 

	  if (description.length == 0){
	    errorMessage = 'the description of terrorist organization cannot be empty';
	    return false;
	  } 

	  return true;
	}

	function generateN3(){
	  
	  terrorBase = 'http://counterterror.mindswap.org/2005/terrorism.owl#';
	  n3_0 = terrorBase + name + ' a ' + terrorBase + 'Organization';
	  n3_1 = terrorBase + name + ' ' + terrorBase + 'hasDescription' + ' ' 
                 + '\'' + description + '\'';

	  if (affiliation.length != 0){
	    n3_2 = terrorBase + name + ' ' + terrorBase + 'affiliation' + ' '
                   + terrorBase + affiliation;
            numberOfN3 = 3;
	  } else {
	    numberOfN3 = 2;
	  }
	}">
    

    <form method="post" name="createInstance">
      Create an instance of terrorist organization - <br><br>
      Name: <input name="name" type="text"> <br>
      Description: <textarea name="description" cols="40" rows="5"><br>
      Affiliation: <input name="affiliation" type="text"><br>
      <input name="Submit" type="submit" value="Create Instance">
    </form>
  </body>
</html>

MINDSWAP is a W3C member