These extensions are added to the OCL language implementation for semantic browser.
Object Properties
In standard OCL, object properties are simple identifiers. For example, the
property name of an object that is referenced by the obj
variable can be accessed with the following expression:
obj.name
In this implementation, the navigation language is able to deal with properties
coming from RDF statements. For this, the syntax allows the use of prefixed URIs
as property identifiers, using a colon character ( : ) as a separator between a
prefix (declared with a namespace declaration) and a short URI. For example the
statement dc:title
of an object referenced by the variable
obj
can be accessed with the following expression:
obj.dc:title
Another syntactic extension has been introduced to allow navigating statements
in the opposite direction. By prefixing the property with a tilde character (
~ ), it is possible to navigate from an object to the
subjects that point to it. For example, the parents of an object that is
referenced by the variable obj
can be accessed with the
following expression, which reverses the navigation of the
syc:treeChild
property:
obj.~syc:treeChild
first() Function
In standard OCL, first() is defined only for ordered
types. In this implementation, it has been extended to support the unordered
collection types.
collection->first(
is equivalent to
collection->any(e|true)
It returns the first element encountered during the iteration of the collection.
Regular Expression
This implementation of OCL supports regular expressions. A pattern literal can be
defined by enclosing the pattern between two /
, for example:
/[0-9]+/
. The syntax of the pattern conforms to Java regex syntax.
The following functions apply to regular expressions:
resource() Function
resource(s)
returns the resource identified by its identifier
string s
Tracing operator !
The postfix operator !
can be used when debugging OCL
navigations. It can be placed after a variable name to indicate that the value
of the variable must be written in the log report during execution.
Example: in the following expression, the value of variable e is logged each
time it is accessed:
navigation titles:
self.syc:treeChild->collect(e | e!.dc:title);
It is also possible to trace the result of an expression. In some cases, the
expression must be enclosed within parentheses.
Example: this computes the sum x+y+z and logs the value of x+y:
(x + y)! + z