jOWL Documentation

Treeview: Navigation Bar:
Enter Search Terms here



jOWL

jOWL - Semantic Javascript Library - Documentation

jOWL is a javascript library that loads and visualizes OWL-DL documents.
The use of jOWL generally implies a two step approach:
  1. Load an owl file with jOWL.load
  2. Upon completion of load, visualize content by querying on the document with jOWL(), and using either custom made representations or any of the jOWL.UI (user Interface) components.
This documentation resides in an OWL-DL file, and can be used as an example to get started with jOWL.
I also strongly advise to get accustomed to the wonderful javascript library jQuery, upon which jOWL is built, and which is vital for building rich user interfaces with jOWL.

Functions specified by jOWL.

jOWL = function(resource, options)

Queries an OWL document loaded with jOWL.load for an OntologyObject with reference equal to 'resource'. Returns a kind of jOWL Ontology Object. Example:

jOWL("wine");

Additional Options

type: 'class' or 'property' for additional type-checking. Most users will not need this.

jOWL.load

jOWL.load = function(path, callback, options)

Initializes/resets jOWL with an OWL-RDFS document.

Optional Parameters

  • path: relative path to the owl document, example: "data/jOWL.owl"
  • callback: function that is triggered when documents is loaded.
  • options: JSON object with options.
    • onParseError: function(msg){}; function to be called when parsing fails
    • reason : true/false, default true
    • locale: set preferrence language, examples en, fr. Is only useful if rdfs:labels are associated with different xml:lang attributes.
Best approach is to define a load as follows:
jOWL.load("path", function(){
declare all your logic inside this function
}, options);

jOWL.parse

jOWL.parse = function(document, options)

initialize jOWL with an existing OWL DOM document. Most users will have no need for this function. See jOWL.load instead.

Optional Parameters


jOWL.toString

jOWL.toString = function(xmlNode)

Returns a String representation of the OWL-RDFS document.

Optional Parameters

  • xmlNode: if specified, only serializes that part of the DOM to String

jOWL.permalink

jOWL.permalink = function(jOWLObject)

Without arguments this function will parse the current url and see if any parameters are defined, returns a JOWL object. With argument it will return a string that identifies the potential permalink for the given entry.


jOWL Objects


Ontology Objects

jOWL.Ontology Objects

Ontology Elements

Common Functions and Objects

Functions and Objects shared by all jOWL Ontology Objects.
  • description(options):
    Returns the content of all specified rdfs:comments that apply to this object.
    options: {split: true} : will wrap each individual comment in 'div' tags
    jOWL('someclass').description({split: true});
  • label():
    Returns a good representation name for this object. If jOWL.options.locale is specified then it will try to match the label against that preference.
    jOWL('someclass').label();
  • bind(jqelem):
    jqelem is a jQuery html element. This function updates the html element with the name of the jOWL object and more. For visualisation purposes.
    jOWL('someclass').bind($('.someClass'));
  • jnode:
    jQuery element that contains the OWL syntax.
  • type
    Type of Ontology element, owl:Class, owl:Thing, ...
  • baseURI
    The namespace of the ontology element.
  • name
    The identifier of the ontology element.

Class

jOWL.Ontology.Class

jOWL javascript equivalent to an owl:Class

Functions and Objects

  • parents():
    Returns a jOWL.Ontology.Array containing this class' direct parents.
  • children():
    Returns a jOWL.Ontology.Array containing this class' direct children.
  • descendants(level):
    Returns a jOWL.Ontology.Array containing this class' descendants, level is a number that specifies how deep to search (1 equals direct children only). The argument level is optional, default 5.
  • hierarchy(options):
    Constructs the entire hierarchy (parents and ancestors) for this owl:Class (see jOWL.UI.Tree as an example). Returns a jOWL.Ontology.Array containing top nodes (classes directly subsumed by 'owl:Thing'). Each node with exception of the leaves (original concept) has a variable invParents (jOWL.Ontology.Array) with child references.
    If options.prune (default true): Performs some additional reasoning to cut down redundant nodes.
  • sourceof(restriction):
    TBW.
    .
  • valueRestrictions(includeAll):
    TBW.
    .
  • individuals():
    TBW.
    .

jOWL.Ontology.Individual

Documentation in progress.


jOWL.Ontology.DatatypeProperty

Documentation in progress.


jOWL.Ontology.ObjectProperty

Documentation in progress.


jOWL.Ontology.Criterium

Documentation in progress.


jOWL.Ontology.Array

Documentation in progress.


jOWL.options

  • reason: default true, enable advanced reasoning (on parents, children, etc...).
  • locale: default false, specify a locale to give preference on visualising rdfs:label's belonging to a certain language. Example: locale: 'fr' set's preference to french terms (if available).
  • defaultlocale: default 'en', e.g. English.
  • onParseError(msg): customizable function, get's called when something is wrong with the syntax of the OWL file.
  • cacheProperties: default true, enables faster access to properties.
  • 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.
  • dictionary: do not overwrite this object, but alter the two settings below instead:
    • dictionary.create: default true, creates a dictionary, used for the autcomplete 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 of the form XX45458 (e.g. numeric code), then it might be more efficient to disable their inclusion.


User Interface

User Interface Components

All user interface components can be re-styled, but for some basic css see the jOWL_xx.css file. All user interface components share 3 important functions:

  • addListener(component): Where component is either another UI component, or an array of UI components. The specified components will respond to selection events in the current components.
  • broadcast(jOWLObject): Will update all listening (see above) components with the specified jOWLObject.
  • propertyChange: Will update this component with the specified jOWLObject. Each component has it's own implementation. Only override if you know what you are doing.
Examples:
var navbar = $('someelement').owl_navbar();
var tree = $('someelement').owl_treeview();
tree.addListener(navbar);


Navigation Bar

Navigation Bar - function(options)

Uses jQuery syntax. Only accepts owl:Class entries. Example:

$('someelement').owl_navbar();

options

None for the time being.

Treeview - function(options)

Uses jQuery syntax. Only accepts owl:Class entries. Example:

$('someelement').owl_treeview();

options

  • rootThing: true/false - default false; if true then topnode is (owl) 'Thing'
  • isStatic: true/false - default false; if static then selections will refresh the entire tree
  • addChildren: true/false - default false; add a given objects children to the treeview as well
  • onSelect: function that can be overwritten to specfy specific behavior when something is selected

Autocomplete Field

Autocomplete - function(options)

Uses jQuery syntax. Should be bound to an 'input' html element of the type 'text'. Example:

$('someinputelement').owl_autocomplete();

options

  • time: responsetime to check for new keystrokes, default 500
  • chars: number of characters needed before autocomplete starts searching, default 3
  • focus: put cursor on the input field when loading, default false
  • limit: limit size of result list to given amount, default 10
  • html: allows specification of a custom function that will reformat the result list to the user's liking. Syntax:
    function(listitem, type, identifier, termarray){
    //listitem = jQuery element wrapped around the 
  • element //type = type of the ontology object, example 'owl:Class' //identifier = identifier (name) of the ontology object //termarray = array of strings, containing the terms associated with this ontology object that match the autocomplete query. }

Individuals Component

Individuals Component - function(options)

Uses jQuery syntax. Only responds to owl:Class entries, shows matching owl:Thing's. Example:

$('someinputelement').owl_individuals();

options

  • title: display the owl:Class name on top, default true
  • tooltip: default false, display additional info in a tooltip, requires the tooltip script.
  • html: if tooltip is enabled, the function that renders the html of the tooltip.
Customisable component
h3>Customisable component - function(customfunction)

Uses jQuery syntax. Example:

$('someinputelement').owl_custom(function(jOWLObject, element){
//define logic here
});

custom function: Argument 'jOWLObject' corresponds to the jOWLObject that fired up this component as a consequence of a selection event. Argument 'element' correspond to the jQuery element that wraps this component. For a better example of usage, see source of this page.



jOWL usecase

Mapping OWL-DL syntax to xHTML Elements - RDFa

This jOWL view is generated a little different than seen in the other demo's. Instead of loading an external OWL-DL file, all OWL syntax is stored in the HTML itself by means of RDFa. Upon pageload jOWL extracts / generates an OWL-DL file from the RDFa which is then visualised with the usual functions.

Major Advantages

  1. Content is accessible to search engine spiders and people who disable javascript. E.g. solves the search engine access issues always seen with any other AJAX implementation.
  2. Much simpler & userfriendly than writing an OWL-DL file. Still requires some effort. But seriously lowers adoption barrier for OWL (also thanks to usage of the cross-browser javascript library jOWL of course).
  3. As opposed to regular html content: Instead of flat representation of content, vertical information (& search) is available.
Show/Hide original documentation

Drawbacks

  1. Only suited for simpler OWL syntax (cfr. documentation: hierarchical information, terms & descriptions) / certain applications. For richer semantics OWL in XML is the better choice.
  2. No load on demand, everything is present on first pageLoad (although possibilities may exist...).


David Decraene.
OntologyOnline.org