Documentation on jOWL version 1.0+.
jOWL is a javascript library that loads and visualizes OWL-DL documents.
The use of jOWL generally implies a two step approach:
I also advise to get accustomed to the jQuery javascript library, upon which jOWL is built, a great foundation for building rich user interfaces with jOWL.
List of Functions in the jOWL namespace.
Main function to access Ontology Objects. Queries a jOWL-initialized (e.g. after jOWL.load, ... has been called) owl / rdfs document for referencable ontology objects.
resource A string matching an Ontology Object's URI (local or absolute, cfr. 'rdf:ID' or 'rdf:about'). Or a jQuery wrapped xml element (with 'rdf:ID' or 'rdf:About' reference), or null if not found.
options Optional. Configuration Object. See Below.
type 'class' or 'property' for additional type-checking. Most users will have no need for this.
A jOWL Ontology Object
jOWL("wine");
jOWL("http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#wine");
Initialize/reset jOWL with an OWL-RDFS document.
path Relative path to the owl document (example: "data/jOWL.owl").
fn Function that is triggered when load is complete. Everything jOWL related should be specified within this function, as it ensures jOWL has been properly initialized.
options Optional. Configuration Object. See Configuration Options for a description of possible settings.
var options = {locale: 'en'};
jOWL.load("mypath", function(){
//All jOWL Logic should be specified here.
}, options);
Initialize jOWL with an existing OWL DOM document or an XML String. Most users will have no need for this function. See jOWL.load instead. See jOWL.load instead.
doc An xmlString or an xmlDocument.
options Optional. Configuration Object. See Configuration Options for a description of possible settings.
Alternative to jOWL.load. Instead of loading an OWL-DL document, try to parse OWL-DL syntax from the current RDFa-embedded document instead.
fn Function that is triggered when load is complete. Everything jOWL related should be specified within this function, as it ensures jOWL has been properly initialized.
options Optional. Configuration Object. See Configuration Options for a description of possible settings.
jOWL.parseRDFa(function(){
//declare all your logic inside this function
}, options);
Returns a String representation of the OWL-RDFS document or XMl node.
xmlNode Optional, an XML node in the owl document. If not specified, then the entire owl document will be converted to String.
String representation of the xmlNode or Document.
Construct or Parse permanent URLs for owl:Classes. Example usage can also be seen in the source code of this page.
The function parses the current url for an owlClass (=URI) argument.
The matching ontology object
//for a given document URL: http://jowl.ontologyonline.org/documentation.html?owlClass=DataObjects var urlreference = jOWL.permalink(); alert(urlreference.URI);
entry Construct an URL (permalink) for the given jOWL Object.
A newly constructed URL (as String).
var newURL = jOWL.permalink(jOWL('DataObjects'));
alert(newURL == http://jowl.ontologyonline.org/documentation.html?owlClass=DataObjects);
Prepares an Object to run SPARQL-DL queries on jOWL. This section lists the javascript functions and parameters, for an overview of the query possibilities: see the SPARQL-DL page
syntax The query, SPARQL-DL abstract query syntax that should be evaluated.
parameters Optional. An object listing pre-defined parameters, that are to be pre-filled in in the query.
options Optional configuration Object.
onComplete Function triggered when query finishes, first parameter corresponds to the results of the query (See result object format below).
childDepth depth to fetch children, default 5, impacts performance
chewsize Query is processed in smaller chunks where available (asynchronous), chewsize indicates the size of the chunks, default 10.
async true/false, default true, query asynchronously. Asynchronous querying prevents browser locking, providing a smoother experience.
jOWL.SPARQL_DL("Type(?x, class)", {"class" : someClass>})
The query will be executed by calling the execute function.
options Same options as above can also be specified on execute instead.
new jOWL.SPARQL_DL("Type(?x, wine)")
.execute({onComplete: function(results){
arr = results.jOWLArray("?x");
}
object.error If an error occurred, this is where the error message is listed.
object.results Associative array containing variable to jOWLObject mappings.
object.assert True, false or undefined. Indicates whether the query evaluated to true or not. See examples above.
object.jOWLArray Function, pass a variable (e.g. ?x) as argument, it will return a jOWL.Ontology.Array containing all jOWL objects mapped to the variable.
[
{"?x" : jOWLObject, "?y" : jOWLObject},
{"?x" : jOWLObject, "?y", jOWLObject}
]
These Functions and Properties are shared by all Ontology Elements. Referencable Ontology Objects are accessed with the jOWL function.
jOWL jOWL Version.
isAnonymous true/false.
baseURI Namespace the object belongs to.
name local Name of the object.
URI local Name (+ URI if Namespace is not the same as the base Namespace), unique.
jnode jQuery wrapped xml element.
An Array of Strings, the content of all "rdfs:comments" specified for this object.
Tip: Use CDATA tags to keep HTML markup in your comments:
<rdfs:comment><![CDATA[ this is a <b>description</b>. ]]></rdfs:comment>
A human-readable representation name for this object. If jOWL.options.locale is specified then it will try to match the label against that preferred language.
jOWL('someclass').label();
Will map the current jOWL object to the given HTML element, for visualisation purposes.
jqelem A jQuery wrapped HTML element.
The jQuery wrapped HTML element.
jOWL('someclass').bind($(someHTMLElement));
jOWL equivalent to an owl:Class.
Extends (inherits all properties and functions) jOWL.Ontology.Thing
isClass true.
A jOWL.Ontology.Array containing this class' direct parents.
A jOWL.Ontology.Array containing this class' direct children.
level Optional, maximum depth to fetch children, default 5.
A jOWL.Ontology.Array containing this class' descendants.
Constructs the entire hierarchy (parents and ancestors) for this owl:Class (see jOWL.UI.Tree as an example). Tree data is stored in the returned Array entries.
addInverse Add a variable invParents (jOWL.Ontology.Array of child references) to each parent node.
A jOWL.Ontology.Array jOWL.Ontology.Array containing topmost parents (classes directly subsumed by 'owl:Thing').
A jOWL.Ontology.Array containing this class' ancestors.
See the sourceof description on Individual.
A jOWL.Ontology.Array of owl:Restrictions satisfying the conditions.
myClass.sourceof(jOWL('someProperty'), jOWL('someTarget'))
.each(function(){
//do something
});
A jOWL.Ontology.Array containing all types/individuals of this class and it's subclasses. For more granularity, use SPARQL-DL type queries instead.
A jOWL.Ontology.Array containing, if any, the Individuals in any oneOf collection declared on this class.
jOWL javascript equivalent to an owl:Thing.
Extends (inherits all properties and functions) jOWL.Ontology.Thing
isThing true.
Get the jOWL.Ontology.Class for this individual.
property Optional, A Property or a jOWL.Ontology.Array of Properties. Or null if no filtering should be applied. Returned Restrictions are filtered on the presence of the given properties.
target Optional, A Class, Individual, Literal/String or a jOWL.Ontology.Array of the previous. Or null if no filtering should be applied. Returned Restrictions are filtered on the presence of the given targets.
options Optional, Configuration Object.
inherited Search Parent/Class Restrictions as well, default true.
transitive Expand on transitive Relations as well, default true.
ignoreGenerics Do not add more generic targets if specific targets are found. default true.
ignoreClasses Only return targets which are Individuals. default false.
valuesOnly Do not return restrictions without a target specified (e.g. cardinality restrictions). default true.
A jOWL.Ontology.Array of owl:Restrictions satisfying the conditions.
var test = jOWL('Year1998').sourceof(jOWL("yearValue"));
alert(test.length == 1);
test = jOWL('Year1998').sourceof(jOWL("yearValue"), "1997");
alert(test.length == 1);
//with options
someThing.sourceof(null, someTarget, {inherited: false, transitive: false });
jOWL equivalent to an rdf:Property. Extends (inherits all properties and functions) jOWL.Ontology.Thing.
isProperty true.
domain The domain of the property as a String (URI). May be null.
range The range of the property as a String (URI). May be null.
var domainObject = jOWL(myProperty.domain);
jOWL equivalent to owl:DatatypeProperty. Extends (inherits all properties and functions) jOWL.Ontology.Property.
isDatatypeProperty true.
Test whether data values (5, "astring", etc) match this properties range.
targetValue Value that will be checked, returns whether or not (true/false) the value falls witih the range of this property.
matchValue Optional, used internally for restriction querying to test an input value (targetValue) against the real restriction target (matchvalue). targetValue may be an expression in this case. If that is the case then the expression will be evaluated and the matchValue will be tested against it. (Example: assert("> 2 && <5", 3) == true if this is a datatypeproperty with range xsd:integer)
jOWL equivalent to an owl:ObjectProperty. Extends (inherits all properties and functions) jOWL.Ontology.Property.
isObjectProperty true.
An array object, tailored for jOWL Ontology Objects. People familiar to jQuery might recognize some similar functionality.
Map this array to some HTML elements for visual representation.
listitem Optional, specify a jQuery wrapped HTML object that will be cloned for each entry. Default a span element.
fn Optional, specify a function that will manipulate each created HTML element. The 'this' keyword and the first argument refer to the newly created jQuery wrapped HTML element. Second argument refers to the jOWL.Ontology.Array Item.
A javascript Array of DOM elements.
var elements = myArray.bind($('<li/>'), function(html, jowlObject){
//manipulate html and or jowlObject.
});
//or for span nodes:
elements = myArray.bind();
$('somelistelement').html(elements);
Merges a target array with this array.
arr An array (native javascript or jOWL.Ontology.Array). No duplicate elements are added in the case of a jOWL.Ontology.Array.
This array.
Check whether this array contains the specified object.
object The object which will be checked for presence in this Array.
true/false
Looping Function, iterates throught the entire array.
fn The function that manipulates each entry of the array. Inside this function, the 'this' keyword and the first argument refer to the current Array element, the second argument to the array position. Explicitely return false to discontinue looping.
reverse Optional, if true then the array will be looped over in reverse order.
This array.
myArray.each(function(item, i){
alert(this.URI);
alert(item.URI);
alert('The index is '+i);
});
myArray.each(function(){
alert("The last element in the array is: "+this.URI);
return false; //will stop looping immediately
}, true);
Looping Function, iterates throught the entire array and removes elements based on the input function.
fn The function that manipulates each entry of the array. Inside this function, the 'this' keyword and the first argument refer to the current Array element, the second argument to the array position. Explicitely return true to keep the element in the array.
This array.
myArray.filter(function(){
return (this.URI == "keepMe");
});
Get a specific element from the Array.
Convert this array into a native javascript Array.
Add an element to this Array.
Add an element to this Array, but only if it is not already present.
Equivalent to an owl:Restriction. Wraps property + target values (relations). Can be used within jOWL.Ontology.Arrays (contains, filter, etc).
isRestriction true/false.
isValueRestriction true/false.
isCardinalityRestriction true/false.
property jOWL Property for this restriction.
target Value for this restriction as a String (URI or Literal). Can be null if this is a cardinalityRestriction instead.
The target as a jOWL Ontology Object.
Object that can be specified as argument for load, parse and parseRDFa.
reason Enable all Reasoning, default true.
locale Set preferred language ('en', 'fr') for visualisation. Only useful in conjunction with 'rdfs:labels' containing 'xml:lang' attributes.
onParseError Function to be called when parsing fails. First argument is the parsing error message. Default: alerts.
niceClassLabels Default true, if no rdfs:labels are found for a given owl:Class, uses some regexp functions to format a more elegant label out of the identifier (add spaces etc).
dictionary.create Default true, creates a dictionary of terms used in this ontology, used for the autocomplete functionality.
dictionary.addID Default true, add identifiers of the ontology objects to the dictionary as well, under the language specified by 'defaultlocale'. If the identifiers are not relevant terms (e.g. of the form XX45458 or other numeric codes etc), then it might be more efficient to disable their inclusion.
All user interface components can easily be re-styled, but some basic styling is provided by the jOWL.css file. All user interface components (widgets) share 3 important functions as specified below. To convert any object into a widget-like object (having the before mentioned functions) one can call: "jOWL.UI.asBroadcaster(theObject);".
item A jOWL Ontology Object, the widget will update itself with the given object.
myWidget.propertyChange(jOWLObject);
Make an other widget listen to this widget's selection events.
widgets Any object, or any javascript array of objects that possess a 'propertyChange' function (see above).
myWidget.addListener(anotherWidget); myWidget.addListener([anotherWidget, yetAnotherWidget]));
item A jOWL Ontology Object, this widget will trigger all propertyChange functions of the widgets that are added as listener (addListener) to this widget. E.g. it will update all dependent widgets.
myWidget.broadcast(jowlObject); //-->updates anotherWidget, yetAnotherWidget;
Visualisation component that shows parents, children and the Class itself.
Extends jOWL User Interface Components. Function that can be called on any jQuery HTML element. Only accepts owl:Class entries.
options Optional, Configuration object.
contentClass String. The css class(es) that will be added to the html element wrapping the main navbar content.
focusClass String. The css class(es) that will be added to the html element representing the selected Ontology Element.
onSelect A function that will be triggered when something is clicked (leading to a broadcast event). First argument is the jOWL Ontology Object that is selected. The 'this' keywords refers to a jQuery wrapped HTML element that was clicked. Explicitely return false to cancel the select.
onPropertyChange A function that will be triggered when this widget receives new input (propertyChange event). First argument is the jOWL Ontology Object that is selected. Explicitely return false to cancel the propertyChange.
var navbar = $('someelement').owl_navbar({
focusClass: "my-focus",
onSelect : function(item){
alert(item);
}
});
Visualisation component that shows the hierarchy of a Class as a tree.
Extends jOWL User Interface Components. Function that can be called on any jQuery HTML element. Only accepts owl:Class entries.
options Optional, Configuration object.
$('someelement').owl_treeview();
Uses jQuery syntax. Should be bound to an 'input' html element of the type 'text'. Example:
$('someinputelement').owl_autocomplete();
function(listitem, type, identifier, termarray){
//listitem = jQuery element wrapped around the Uses jQuery syntax. Only responds to owl:Class entries, shows matching owl:Thing's. Can be entirely replaced by an appropriate Property Lens, is maintained for ease of use only. Example:
$('someinputelement').owl_individuals();
Uses jQuery syntax. Example:
$('someinputelement').owl_propertyLens(options);
Very flexible component, relies heavily on HTML templating, which means that most functionality can be tuned by altering the HTML inside the element converted into a propertyLens (hardly any javascript required). This documentation describes the additional javascript settings that can be added, but see the blog post for an extensive description of the HTML templating functionality.
"rdfs:label" : {split: ", ", "rdfs:label" :
function(){ //'this' keyword refers to HTML element}} )
"sparql-dl:PropertyValue(owl:Class, ?p, ?x)" : {"?p":
function(){ //'this' keyword refers to HTML element }}