What is the SWRL Editor? (6HT)
The SWRL Editor is an extension to the Protege-OWL SWRLTab that supports the editing of SWRL rules. It can be used to create SWRL rules, edit existing SWRL rules, and read and write SWRL rules. (7TB)
The SWRL Submission does not specify a presentation syntax for the language so implementors must define a suitable syntax. The presentation syntax supported by the SWRL Editor is described here. This link can also serve as an introduction to the SWRL language. (723)
How do I activate the SWRL Editor? (6HV)
The SWRL Editor is included as part of Protege-OWL. It is primarily accessible through the SWRLTab within it. A screenshot of the SWRLTab is shown below. (6HW)
This tab should be visible for all OWL ontologies that reference the SWRL ontology. It is disabled by default if the loaded ontology does not reference this ontology. (6HY)
To activate the SWRLTab in a project that does not reference this ontology, go to Project | Configure in Protege-OWL and check the "SWRLTab" box. The tab will then appear. The user can then navigate to this tab, whereupon they will be given the option to reference the necessary SWRL ontology files. (6HZ)
Are there any example SWRL rules that I can play with? (6I0)
There is a simple example OWL/SWRL ontology available in our ontology library at family.swrl.owl. Thanks to Christine Golbreich for providing these rules. (6I1)
How do I use the editor to examine SWRL rules in a OWL ontology? (6I2)
Assuming the SWRLTab is enabled, there are two ways of interacting with the SWRL Editor: (6I3)
(1) The primary mechanism is to go the the SWRLTab itself. This tab shows all the SWRL rules in the loaded ontology in tabular form. (6I4)
(2) A second mechanism allows users to find rules relating to the currently selected OWL class, property, or individual in the respective tabs for those entities. For example, if a user is examining a class using the OWL Classes tab, they can click on the arrow symbol at the bottom left of class editor subpane to bring up a list of SWRL rules that refer to that class. The same mechanism applies in the properties and individuals tabs. The screenshot below shows the list of rules that contain a reference to the hasParent property. (6I5)
How do I edit SWRL rules? (6I7)
There are two editing modes for rules. Rules can either be edited in place in the table that contains them or a multi-line editor can be popped up. The difference between the two modes is primarily visual: the exact same interaction mechanisms apply in both modes, though the multi-line editor has some additional options. (6I8)
To edit a rule in place, simply left-click on the rule text. A blinking cursor will appear and an icon panel will pop up. The rule can then be directly edited. To save the edited rule, press the Enter key. To abandon editing, press the Escape key. (6I9)
To edit in a multi-line editor, right-click on the rule and select "Edit rule in multi-line editor..." from the popup menu. A modal popup dialog box will appear. It will contain a text area to edit a rule and the same icon panel that was displayed for in place editing. To save the edited rule press the "Ok" button. To abandon editing, press the "Cancel" button. This dialog also can be used to edit the name and annotations of the rule. (6IA)
In either mode, the editor will not allow an erroneous or incomplete SWRL rule to be saved. (6IC)
While editing, the nerd on the right of the icon panel will smile if he is happy with the rule as entered. If the rule is incomplete or has an error, he will look unhappy. To determine why he is unhappy, click on the nerd and an error will be displayed in the icon panel. (6ID)
What are all those pretty icons on the icon panel? (6IE)
SWRL rules can be entered completely from the keyboard. However, in many cases the user may wish to select the appropriate OWL entities from the loaded ontology rather than typing the entity names. The icon panel provides selection dialog boxes to select OWL classes, properties, and individuals, for example, and also includes shortcuts and selection dialog boxes for various other entities. The tool tips text for each icon explains its purpose. (6IF)
Does the SWRL Editor have auto-complete? (6IG)
Yes. Pressing the Tab key while editing an entity name will auto-complete that name if it has a unique expansion or will bring up a selection box containing the list of possible completions if it does not. (6IH)
For example, typing xsd: followed by the Tab key in the SWRL Editor text area will pop up a dialog box that will list all available datatypes. The datatypes icon can also be selected from the icon panel to display this list. (71Y)
Similarly, typing swrlb: followed by the Tab key in the SWRL editor text area will pop up a dialog box that will list all currently accessible built-ins in that namespace. The built-in icon can also be clicked on the icon panel to display this list. (71Z)
The editor will also dynamically expand annotation values used to refer to OWL classes, properties, and individuals. Typing the single quote (') character followed by the Tab key will bring up all annotation values that are selected to display the names of OWL entities. Expansion will also work for partial annotation values. (AMG)
How do I create a new SWRL rule? (6II)
A SWRL rule can be created by clicking on the arrow symbol on the top right of the SWRL editing panel. The multi-line editor pops up and a rule can then be created and saved. (6IJ)
How do I delete a SWRL rule? (6IK)
A SWRL rule can be deleted by selecting the rule in the SWRL editor panel and clicking on the X symbol on the top right of the editor panel. (6IL)
How do I save SWRL rules? (6KM)
SWRL rules are stored as OWL individuals with their associated OWL ontology so can be saved using the normal Protege-OWL file saving mechanism. When a saved ontology containing SWRL rules is reloaded, the SWRL editor will be enabled automatically, and can be used to examine the saved rules. (6KO)
Does the SWRL Editor validate SWRL rules? (6KR)
The SWRL Editor performs basic syntactic and semantic checking. It will ensure that a rule is syntactically correct before it is saved and will also ensure that any references to OWL entities are valid. However, the editor does not perform any integrity checking between rules in an ontology, does not attempt to ensure that rule do not conflict with OWL axioms, and does not prevent the user from writing well formed but meaningless rules. (6KS)
Also, the SWRL specification does not specify that checking should be performed on the types of arguments to built-ins so the SWRL Editor does not perform this checking. In any case, the OWL definition of a SWRL built-in by default does not specify the types of arguments that the built-in is expecting so a general argument type checking mechanism is not possible. A built-in definition can (optionally) specify the number of arguments it is expecting but these are currently ignored. (8IK)
Does the SWRL Editor perform any inference? (6KT)
The SWRL Editor itself does not perform any inference. However, a bridge mechanism is provided to allow interoperation with rule engines. At present, the Jess rule engine is supported, and is accessible through the SWRLJessTab. (72X)
Can I create and manipulate SWRL rules at the Protege-OWL API level without using the SWRL Editor? (6KV)
Yes. The SWRL Editor uses a separate back-end factory that can be used to manipulate the OWL individuals that represent SWRL rules. It can be used to create and edit SWRL rule elements programatically. This factory provides a Java API to create SWRL rules and to examine and manipulate existing SWRL rules in a knowledge base. Java applications can use this factory to interact with SWRL rules at the Protege-OWL API level and completely bypass the editor. (6K6)
Please see the SWRL Factory FAQ for more details. (6KW)
Can I edit SWRL rules in Protege-OWL without using the SWRL Editor? (6KX)
Yes - OWL individuals are used to store SWRL rules so these individuals can be manipulated directly using the normal Protege-OWL editing mechanisms. However, direct editing of the individuals used to represent SWRL rules is not recommended unless you know what you are doing. (6KY)
How does the SWRL Editor store rules? (6KP)
SWRL rules are stored as OWL individuals in an OWL ontology. The ontology that describes these individuals is here. OWL ontologies are typically saved as OWL/RDF files. (6KQ)
Can I use third-party software to work with the rules generated by the SWRL Editor? (6KZ)
Yes. SWRL rules are ultimately represented as OWL individuals contained in OWL ontologies, which are typically saved as OWL/RDF files. Third party software can work directly with the rules described in these files. One minor caveat is that Protege-OWL uses the Jena parser library to generate these files, so parsing can be difficult - though not impossible - with normal XML parsers. Jena can always be used, however, to parse these files in Java applications. (6K7)
How does the SWRL Editor deal with invalid rules? (8J6)
The SWRL Editor will only allow saving of rules that refer to currently valid OWL classes, properties and individuals. However, those entities may be invalidated later due to deletions or name changes. For example, if a SWRL rule refers to a class A in an imported ontology with the prefix epoch and that class name is later changed, the reference will no longer be valid. When displaying the rule with this invalid reference, the editor will replace the previously valid reference name with the error indication <INVALID_CLASS[epoch:A]>. Similar errors will be displayed for invalid references to individuals and properties. The error will identify the previously valid OWL entity name. Deletion from the same ontology are indicated by error indications of the form <DELETED_CLASS>, <DELETED_PROPERTY>, <DELETED_INDIVIDUAL> and so on. In this case, the previously valid reference is unknown. (8J9)
While the editor will allow such invalid references to remain in an ontology indefinitely, it will not allow the offending rules to be saved if they are edited until all broken references are fixed. (8J8)