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
- Create an annotation on the class whose instances are to be created.
- Within the annotation, create a form with data input entries (e.g. textfield, textarea). You need to name the form as createInstance, so SWOOP knows this form is for the purpose of instance creation.
- Within the tag <javascript> write all the Javascript code in the attribute of code. If you need to use quotes in your Javascript, use single quote.
- The function verify() should return true if all the data is valid otherwise it should return false. If you want to display an error message for an invalid data, assign the message as a string to the variable errorMessage.
- The function generateN3() should return a list of variables which contains the triples that used by the SWOOP to create instances and properties. You should assign the number of triples to the variable numberOfN3. Each triple should be assigned as a string to variables n3_x (where x is an index starting from 0). For example, if you have 3 triples, you should assign them to n3_0, n3_1 and n3_2.
- The triples follow the N3 notations except that you don't have to use < and > to enclose the full URI. To specify an instance of a class, the triple should be written as Full-URI-of-Instance a Full-URI-of-class. To specify a datatype property, the triple should be written as Full-URI-Of-Subject Full-URI-Of-Property Data-Value. To specify an object property, the triple should be written as Full-URI-Of-Subject Full-URI-Of-Property Full-URI-Of-Object.
