Libretto Built-in Functions

This document has been generated from the ontology builtins.mvx, which formally describes Libretto's built-in functions.



The namespace for builtins is

http://ontobox.org/libretto/builtins

The predefined prefix is fn (that is, to call Count/0 we should write fn:Count()).



Function Types


1 Sequence function


2 String function


3 Accessors


4 Date/Time Function

>5 Input/output function


6 Type Function


7 Ontobox model function


8 Map Function


9 Meta function


10 Aux




1 Sequence function

Count/0

description:
Counts the number of elements in the collection
format:
Count() as Integer
type:
Collection-wise

Distinct/0

description:
Removes the repetitions of values in the collection
format:
fn:Distinct() as Sequence
type:
Collection-wise

Index/1

description:
Returns $i'th element of the collection. If $i < 0 counts the element from the end of the sequence, that is, takes size() + $i element. Index/1 is a collection-wise version of the 'at' operation.
format:
fn:Index($i as Integer) as Value
type:
Collection-wise
examples:
(1,2,3)/fn:Index(0); # = (1)
(1, 2, 3) / fn:Index(-1); # = (3)

Last/0

description:
Returns the last element of the context sequence
format:
fn:Last() as Value
type:
Collection-wise

Map-split-starts/3

description:
format:
fn:Map-split-starts(modified as Path, check-path as Path, new-key as String)
type:
Collection-wise

Remove-at/1

description:
'Destructively' removes the element of the context sequence at the position idx
format:
Sequence Remove-at(idx as xsd:index)
type:
Collection-wise
examples:
(1,2,3)/fn:Remove-at(1); # = (1,3)

Reverse/0

description:
Reverses the order of elements in the context sequence.
format:
Sequence / fn:Reverse()
type:
Collection-wise
examples:
(1, 2, 3) / fn:Reverse(); # = (3, 2, 1)

Slice/2

description:
Returns the sub-sequence of the context sequence starting at the position start (the first position number is 0) and having length length. If length < 0, the function collects all elements from the start position to the end of the collection. If start < 0, the function counts down the starting position from the end of the collection (the last element has number -1).
format:
Sequence / fn:Slice(start as Integer, length as Integer)
type:
Collection-wise
examples:
(1,2,3,4,5,6,7)/fn:Slice(2, 3) # = (3,4,5)
(1,2,3,4,5,6,7)/fn:Slice(3, -1) # = (4,5,6,7)
(1,2,3,4,5,6,7)/fn:Slice(-2, 2) # = (5,6)
(1,2,3,4,5,6,7)/fn:Slice(-2, -1) # = (1,2,3,4,5,6)

Split-col/5

description:
The same as Split-col/3 but the user can determine his/her own property names of map objects: &{ := eval(), := }
format:
Split-col(chkpath as PathTerm, key as PathTerm, type as String, keyname as String, valuename) as Sequence of Map
type:
Collection-wise

Split-col/3

description:
Splits the context sequence by portions depending on the splitting : Each portion is represented by a map element &{key := eval(), value := } "different" - the initial collection is splitted between two neighbor elements, if the value of path on them is different "starts.with" - the element starts new portion if path on it is true (non-empty) "starts.after" - the next portion starts immediately after the elements, on which is true (non-empty) selects elements determining splitting
format:
Split-col(chkpath as PathTerm, keypath as PathTerm, type as String) as Sequence of Map
type:
Collection-wise

Split-col/1

description:
Splits the context collection by portions of lng elements. Each portion is formed as a map object with two properties: "key" contains the number of the starting element in the initial collection; "value" contains the collection containing the current portion of elements
format:
Split-col(lng as Integer) as Sequence of Map
type:
Collection-wise
examples:
(1,2,3,4,5,6,7)/fn:Split-col(3)/("[{key}] {value/join("-")}"); # = ("[0] 1-2-3", "[3] 4-5-6", "[6] 7")

Split-col-starts/2

description:
Splits the context collection by the quoted condition 'checkpath' with a sequence of temporary anomimous objects having property 'keyname' of which contain the portion of elements from the context collection.
format:
fn:Split-col-starts(checkpath, keyname as xsd:string)
type:
Collection-wise

add/3

description:
'Destructively' `adds the value to the sequence at the position idx
format:
fn:add(seq as Sequence, value, idx as xsd:integer)
type:
Static
examples:
fn:add((1,2,3), 4, 2) # = (1, 2, 4, 3)

add/2

description:
'Destructively' adds the value (2nd arg) to the sequence (1st arg).
format:
fn:add(seq as Sequence, value)
type:
Static
examples:
fn:add((1,2,3), 4); # = (1,2,3,4)

iterator/1

description:
Creates a hidden iterator and returns the first value of the collection.
format:
fn:iterator(col as Collection) as Value (with additional features for iteration)
type:
Static

next/1

description:
Returns the next value of the iteratation hidden in val
format:
fn:next(val as IteratedValue)
type:
Static

o-all/0

description:
Collects all objects, the values of all o-properties of the current context object.
format:
o-all() as Sequence of Object
type:
Element-wise

range/3

description:
Lazily generates the sequence of integers between 'start' and 'end' with step 'stetp'.
format:
fn:Range(start as xsd:integer, end as xsd:integer, step as xsd:integer)
type:
Static

range/2

description:
Lazily generates the sequence of integers between 'start' and 'end' with step 1.
format:
fn:Range(start as xsd:integer, end as xsd:integer)
type:
Static
examples:
fn:Range(1, 100)
fn:Range(4, 1) # = (4,3,2,1)

t-all/0

description:
Collects all data, the values of all t-properties of the current context object.
format:
t-all() as Sequence of Data
type:
Element-wise

3 String function

Codes-to-string/0

description:
Returns the string obtained from the ordered collection of integers.
format:
fn:Codes-to-string() as String
type:
Collection-wise
examples:
(100, 101, 102)/fn:Codes-to-string(); # = ("def")
(100, 101, 102)[fn:Codes-to-string()="def"]; # = (100, 101, 102)
(100, 101, 102)[fn:Codes-to-string()="efg"]; # = ()

Codes-to-strings/1

description:
Returns the collection of strings obtained from the ordered collection of integers. $separator is an integer, which separates strings.
format:
fn:Codes-to-strings($separator as Integer)
type:
Collection-wise
examples:
(101, 100, 102, 100, 103)/fn:Codes-to-strings(100); # = ("e", "f", "g")
(101, 100, 102, 100, 103)[fn:Codes-to-strings(100) = "f"]; # = (101, 100, 102, 100, 103)
(101, 100, 102, 100, 103)[fn:Codes-to-strings(100) = "h"]; # = ()

Join/1

description:
Joins the collection of stings with optional separator. If no separator needed, use $separator = "".
format:
fn:Join($separator as String) as String
type:
Collection-wise
examples:
("a", "b", "c")/fn:Join(" - "); # = ("a - b - c")
("a", "b", "c")[fn:Join(" - ") = "a - b - c"]; # = ("a", "b", "c")
("a", "b", "c")[fn:Join(" = ") = "a - b - c"]; # = ()

Strings-to-codes/1

description:
Returns the ordered collection of integers by decoding the strings of the input collection and separating them with $separator
format:
fn:Strings-to-codes($separator as Integer)
type:
Collection-wise
examples:
("abc", "def")/fn:Strings-to-codes(0); # = (97, 98, 99, 0, 100, 101, 102)
("", 1, "")/fn:Strings-to-codes(115); # = (115) # integer is ignored
("abc", "def")[fn:Strings-to-codes(0) > 100]; # = ("abc", "def") # checks the whole
("abc", "def")/fn:Strings-to-codes(0)[. > 100]; # = (101, 102)

bin-to-hex/0

description:
Converts a binary in the Base64 string format into string Hexadecimal formt
format:
Based64Binary / fn:bin-to-hex() as HexBinary
type:
Element-wise
examples:
("R0lGODlhAQABAIAAAAB9QwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==") / fn:bin-to-hex() # = ("47494638396101000100800000007d4300000021f90400000000002c00000000010001000002024401003b")

compare/1

description:
Returns -1, 0, 1 if the context string is less than, equal to or greater than $str, respectively If the context object or the argument is not a string, nil is returned
format:
compare($str as String)
type:
Element-wise
examples:
("a", "b", "c")/compare("b"); # = (-1, 0, 1)
("a", "b", "c")[compare("b")<=0]; # = ("a", "b")

contains/1

description:
true if the input string contains $str as a substring
format:
contains($str as String)
type:
Element-wise

ends-with/1

description:
the context string value, if it ends with $str, false otherwise
format:
ends-with($str as String)
type:
Element-wise
examples:
("john", "paul", "james", "tom", "jan")[ends-with("n")]; # = ("john", "jan")

group/1

description:
Returns the value of i-th group after the application of matches/3 in regexp.
format:
fn:group(gr as xsd:integer) as xsd:string
type:
Element-wise

hex-to-bin/0

description:
Converts a binary in the hexadecimal string format into string Base64 formt
format:
HexBinary / fn:hex-to-bin() as Base64Binary
type:
Element-wise
examples:
("47494638396101000100800000007d4300000021f90400000000002c00000000010001000002024401003b") / fn:hex-to-bin(); # = ("R0lGODlhAQABAIAAAAB9QwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==")

lower-case/0

description:
Returns the modified input string, in which each upper-case letter is replaced with its lower-case counterpart. All the other characters stay in their original form.
format:
lower-case() as String
type:
Element-wise
examples:
("AaBbCc", "12Aab")/lower-case(); # = ("aabbcc", "12aab")

matches/2

description:
The function returns true if $input matches the regular expression supplied as $pattern; otherwise, it returns false. Unless the metacharacters ^ and $ are used as anchors, the string is considered to match the pattern if any substring matches the pattern. But if anchors are used, the anchors must match the start/end of the string (in string mode), or the start/end of a line (in multiline mode). Special variables $0, $1,..., $9 are assigned substrings of the input string matching the segments of $pattern encloded in (...), as usual. Variables $0, ... are global in the context of meta2path. Flags: - m: If present, the match operates in multiline mode. Otherwise, the match operates in string mode. - i: If present, the match operates in case-insensitive mode. Otherwise, the match operates in case-sensitive mode. In case-sensitive mode, a character in the input string matches a character specified by the pattern only if the Unicode code-points match. In case-insensitive mode, a character in the input string matches a character specified by the pattern if there is a canonical caseless match between the two characters as defined in section 2.5 of Unicode Case Mappings.
format:
matches($pattern as String, $flags as String) as String
type:
Element-wise
examples:
("Aaaaab")/matches("(a*)(b)", "i"); # = ("Aaaaab")
fn:group(0); # = ("Aaaaab")
fn:group(1); # = ("Aaaaa")
fn:group(2); # = ("b")
("1234", "abcd")[matches("(.*)(.)", "")[$2 = "4"]]; # = ("1234")
fn:group(0); # = ("abcd")
fn:group(1); # = ("abc")
fn:group(2); # = ("d")

nl/0

description:
returns a new line string (Java's System.getProperty("line.separator"))
format:
nl()
type:
Static

replace/3

description:
The function returns the String that is obtained by replacing all non-overlapping substrings of this string, that match the given $pattern with the instantiated $replacement string. If two overlapping substrings of the context string both match the $pattern, then only the first one (that is, the one whose first character comes first in the $input string) is replaced. Within the $replacement string, the variables $1 to $9 may be used to refer to the substring captured by each of the first nine parenthesized sub-expressions in the regular expression. A literal $ symbol must be written as \$. For each match of the pattern, these variables are assigned the value of the content of the relevant captured sub-expression, and the modified replacement string is then substituted for the characters in $input that matched the pattern. Flags are the same as for matches/2
format:
replace($pattern as String, $replacement as String, $flags as String) as String
type:
Element-wise
examples:
("...012...a1b...", " D1d ")/replace("(.)1(.)", "$21$1", ""); # = ("...210...b1a...", " d1D ")
("012", "D1d")[replace("(.)1(.)", "$21$1", "")/contains("2")]; # = ("012")

split/2

description:
Splits the context string into a collection of strings, treating any substring which matches $pattern as a separator. Flags are interpreted as in matches/2
format:
split($pattern as String, $flags as String) as Sequence
type:
Element-wise
examples:
("...012...a1b", "-D1d-")/split("\d", ""); # = ("...", "", "", "...a", "b", "-D", "d-")
("...012...a1b", "-D1d-")[split("\d", "")/string-length() = 1]; # = ("...012...a1b") # the split collection of the first string contains "b".

starts-with/1

description:
the context string value, if it starts with $str, false otherwise
format:
starts-with($str as String) as String
type:
Element-wise
examples:
("john", "paul", "james", "tom", "jan")/starts-with("j"); # = ("john", "james", "jan")

string-length/0

description:
Returns the length of the input string
format:
string-length() as Integer
type:
Element-wise
examples:
("1", "12", "123", "1234")/string-length(); # = (1, 2, 3, 4)
("1", "12", "123", "1234")[string-length() > 2]; # = ("123", "1234")

string-pad/1

description:
Returns a string consisting of $counter copies of the input string concatenated together without any separators. Returns the zero-length string if $counter = 0.
format:
string-pad($counter as Integer) as String
type:
Element-wise
examples:
("a", "bc")/string-pad(5); # = ("aaaaa", "bcbcbcbcbc")
("a", "bc")[string-pad(5)/string-length() = 5]; # = ("a")

string-to-codes/0

description:
Returns the ordered collection of integers obtained by decoding the strings of the input collection
format:
string-to-codes()
type:
Element-wise
examples:
("abc", "def")/string-to-codes(); # = (97, 98, 99, 100, 101, 102)
("abc", 1, "def")/string-to-codes(); # = (97, 98, 99, 100, 101, 102) # integer is ignored
("abc", "def")[string-to-codes()=100]; # = ("def") # 100 is code for 'd'. Strings encoded separately in the predicate, because the function is element-wise.

substring/2

description:
Returns a substring of the input string starting at $location and continuing for $length characters. If the location and length are not integers then those chars are selected, whose position $p obeys round($location) <= $p < round($location) + round($length) The first character starts at position 1. if $location < 0 then starts from the end of the string if $length < 0 then continues till the end (the beginning in case $location < 0) of the string
format:
substring($location as Digital, $length as Digital)
type:
Element-wise
examples:
("123456789")/substring(3, 2); # = ("34")
("123456789")/substring(3.2, 2.7); # = ("345")
("123456789")/substring(-3, 2); # = ("67")
("123456789")/substring(3, -1); # = ("3456789")
("123456789")/substring(-3, -1); # = ("1234567")
("123456789", "abscde")/substring(-3, 3); # = ("567", "bsc")
("123456789", "abscde")[substring(-3, 3)="bsc"]; # = ("abscde")
("123456789", "abscde", "a", 2)/substring(-3, 3); # = ("567", "bsc") # string "a" is too short, thus ignored. Integer is also ignored.

trim/0

description:
Returns a copy of the string, with leading and trailing whitespace omitted.
format:
trim() as String
type:
Element-wise
examples:
(" 123 ")/trim(); # = ("123")
(" ", " 123 ")[trim()=""]; # = (" ")

upper-case/0

description:
Returns the modified input string, in which each lower-case letter is replaced with its upper-case correspondent. All the other characters stay in their original form.
format:
upper-case() as String
type:
Element-wise
examples:
("AaBbCc", "12Aab")/upper-case(); # = ("AABBCC", "12AAB")

4 Accessors

object-classes/0

description:
This function returns the URI of the classes to which this object belongs
format:
object-classes() as String
type:
Element-wise
examples:
(&p:paul, &p:john)/object-classes()/fn:Distinct(); # = ("http://teacode.com/people#man")
(&p:paul, b:yes)[object-classes()[contains("ers")]]; # = ()
&p:tom/object-classes(); = ("http://teacode.com/people#man", "http://teacode.com/people#employee")
*[object-classes()/contains("ee")]; # = (tom) # Only Tom is employEE

object-properties/0

description:
Returns the collection of URI strings identifying the properties of the input object
format:
object-properties() as String
type:
Element-wise
examples:
&p:tom/object-properties(); # = ("http://teacode.com/people#spouse", "http://teacode.com/people#hasChild", "http://teacode.com/people#position", "http://teacode.com/people#salary", "http://teacode.com/people#age", "http://teacode.com/people#name", "http://teacode.com/people#surname")
&p:tom/object-properties()[uri-kind()="TProperty"]; # = ("http://teacode.com/people#position", "http://teacode.com/people#salary", "http://teacode.com/people#age", "http://teacode.com/people#name", "http://teacode.com/people#surname")
*[object-properties()/contains("#position")]; # = (tom)

to-string/0

description:
Returns the string representation of the entity or data
format:
to-string() as String
type:
Element-wise
examples:
&p:tom/to-string(); # = ("http://teacode.com/people#tom")
*[to-string()/uri-object()/@name = "Marie"]; # = (marie)
(1, "1", 1.2)/to-string(); # = ("1", "1", "1.2")
(1, "1", 1.2)[to-string()/contains(".")]; # = (1.2)

value-kind/0

description:
This function returns a String representing the values's kind: either Object, Quoted (for quoted expressions), String, or Integer
format:
value-kind() as String
type:
Element-wise
examples:
(1, 2, "3", 1.2)/value-kind(); # = {"Integer", "Integer", "String", "Float"}
&p:john/value-kind(); # = {"Object"}
(1, 2, "3")[value-kind() # = "String"]; = {"3"}
(`**) / fn:value-kind(); # = ("Quoted")

5 Date/Time Function

dt-after/1

description:
Returns those context date/time values which are after the date/time in the 1st argument.
format:
dateTime /fn:dt-after(d as dateTime)
type:
Element-wise
examples:
("1980-01-01T00:20:34.567Z")/fn:dt-after("1970-01-01T00:20:34.567Z"); # = ("1980-01-01T00:20:34.567Z")

dt-before/1

description:
format:
xsd:dateTime / fn:dt-before(d as xsd:dateTime)
type:
Element-wise
examples:
("1970-10-10", "2003-10-12", "2002-10-12T10:15:00.000Z")/fn:dt-before("2002-10-12T11:00"); # = ("1970-10-10") ; the 3rd is after, if default time is less than UTC-1

dt-convert/2

description:
Converts the context date/time value from one time zone (1st argument) to the other (2nd argument)
format:
xsd:dateTime / fn:dt-convert(tz1 as xsd:string, tz2 as xsd:string)
type:
Element-wise
examples:
("2009-10-25T01:12:34.567")/fn:dt-convert("asia/irkutsk", "default"); # = ("2009-10-24T17:12:34.567") from irkutsk to default utc

dt-format/1

description:
Sets output format for date/time presentation. 1st argument contains the format string. The context values are date values, which must be represented in the specified format.
format:
date / fn:dt-format(format as xsd:string)
type:
Element-wise
examples:
("1970-10-10", "2003-10-12", "2002-10-12T10:15:00.000Z")/fn:dt-format("dd/MM/yyyy"); # = ("10/10/1970", "12/10/2003", "12/10/2002")

dt-get-day-of-month/0

description:
Returns the number of the day in the date's month.
format:
dateTime /fn:dt-get-day-of-month() as xsd:integer
type:
Element-wise
examples:
("2003-10-12 00:20:34.567Z")/fn:dt-get-day-of-month(); # 390:: = (12)

dt-get-day-of-week/0

description:
Returns the number of the day in the current week in the context date/time.
format:
dateTime / fn:dt-get-day-of-week()
type:
Element-wise
examples:
("2009-09-15T00:20:34.567Z")/fn:dt-get-day-of-week(); # = (3) ; Tue (Sat = 0)

dt-get-day-of-year/0

description:
Gets the day-number in the year of the context date/time value.
format:
xsd:dateTime / fn:dt-get-day-of-year()
type:
Element-wise
examples:
("2009-09-15T11:21:34.567Z", "1970-01-01 05:00") / fn:dt-get-day-of-year(); #2 = (258, 1)

dt-get-hours/0

description:
Returns the current hour of the context date/time.
format:
dateTime / fn:dt-get-hours()
type:
Element-wise
examples:
("2009-09-15T11:21:34.567Z", "1970-10-10 05:00")/fn:dt-get-hours(); # = (20, 5); default time is (UTC-9)

dt-get-minutes/0

description:
Get the minutes value of the context date/time.
format:
dateTime /fn:dt-get-minutes()
type:
Element-wise
examples:
("2009-09-15T03:21:34.567Z", "1970-10-10 03:02")/fn:dt-get-minutes(); # = (21, 2)

dt-get-month/0

description:
Returns the month number in the current year in the context date.
format:
dateTime / fn:dt-get-month()
type:
Element-wise
examples:
("1987-06-12")/fn:dt-get-month(); # = (5) ; starting with 0 (Jan)

dt-get-seconds/0

description:
Get seconds value of the context date/time.
format:
dateTime / fn:dt-get-seconds()
type:
Element-wise
examples:
("2009-09-15 03:21:34.567Z", "1970-10-10T03:02")/fn:dt-get-seconds(); # = (34, 0)

dt-get-year/0

description:
Returns the number of the year in the context date/time.
format:
dateTime / fn:dt-get-year()
type:
Element-wise
examples:
("2009-09-15T03:21:34.567Z", "1970-10-10T03:02", "70-10-01")/fn:dt-get-year(); # = (2009, 1970, 70)

get-available-tz/0

description:
gets the sequence of the available time zone names as strings.
format:
fn:get-available-tz()
type:
Static
examples:
fn:get-available-tz()<<.>>/fn:lower-case(); # = ("act", "aet", "agt", "art", "ast", "africa/abidjan", "africa/accra", "africa/addis_ababa", "africa/algiers", "africa/asmara", "africa/asmera", "africa/bamako", "africa/bangui", "africa/banjul", "africa/bissau", "africa/blantyre", "africa/brazzaville", "africa/bujumbura", "africa/cairo", "africa/casablanca", "africa/ceuta", "africa/conakry", "africa/dakar", "africa/dar_es_salaam", "africa/djibouti", "africa/douala", "africa/el_aaiun", "africa/freetown", "africa/gaborone", "africa/harare", "africa/johannesburg", "africa/kampala", "africa/khartoum", "africa/kigali", "africa/kinshasa", "africa/lagos", "africa/libreville", "africa/lome", "africa/luanda", "africa/lubumbashi", "africa/lusaka", "africa/malabo", "africa/maputo", "africa/maseru", "africa/mbabane", "africa/mogadishu", "africa/monrovia", "africa/nairobi", "africa/ndjamena", "africa/niamey", "africa/nouakchott", "africa/ouagadougou", "africa/porto-novo", "africa/sao_tome", "africa/timbuktu", "africa/tripoli", "africa/tunis", "africa/windhoek", "america/adak", "america/anchorage", "america/anguilla", "america/antigua", "america/araguaina", "america/argentina/buenos_aires", "america/argentina/catamarca", "america/argentina/comodrivadavia", "america/argentina/cordoba", "america/argentina/jujuy", "america/argentina/la_rioja", "america/argentina/mendoza", "america/argentina/rio_gallegos", "america/argentina/salta", "america/argentina/san_juan", "america/argentina/san_luis", "america/argentina/tucuman", "america/argentina/ushuaia", "america/aruba", "america/asuncion", "america/atikokan", "america/atka", "america/bahia", "america/barbados", "america/belem", "america/belize", "america/blanc-sablon", "america/boa_vista", "america/bogota", "america/boise", "america/buenos_aires", "america/cambridge_bay", "america/campo_grande", "america/cancun", "america/caracas", "america/catamarca", "america/cayenne", "america/cayman", "america/chicago", "america/chihuahua", "america/coral_harbour", "america/cordoba", "america/costa_rica", "america/cuiaba", "america/curacao", "america/danmarkshavn", "america/dawson", "america/dawson_creek", "america/denver", "america/detroit", "america/dominica", "america/edmonton", "america/eirunepe", "america/el_salvador", "america/ensenada", "america/fort_wayne", "america/fortaleza", "america/glace_bay", "america/godthab", "america/goose_bay", "america/grand_turk", "america/grenada", "america/guadeloupe", "america/guatemala", "america/guayaquil", "america/guyana", "america/halifax", "america/havana", "america/hermosillo", "america/indiana/indianapolis", "america/indiana/knox", "america/indiana/marengo", "america/indiana/petersburg", "america/indiana/tell_city", "america/indiana/vevay", "america/indiana/vincennes", "america/indiana/winamac", "america/indianapolis", "america/inuvik", "america/iqaluit", "america/jamaica", "america/jujuy", "america/juneau", "america/kentucky/louisville", "america/kentucky/monticello", "america/knox_in", "america/la_paz", "america/lima", "america/los_angeles", "america/louisville", "america/maceio", "america/managua", "america/manaus", "america/marigot", "america/martinique", "america/mazatlan", "america/mendoza", "america/menominee", "america/merida", "america/mexico_city", "america/miquelon", "america/moncton", "america/monterrey", "america/montevideo", "america/montreal", "america/montserrat", "america/nassau", "america/new_york", "america/nipigon", "america/nome", "america/noronha", "america/north_dakota/center", "america/north_dakota/new_salem", "america/panama", "america/pangnirtung", "america/paramaribo", "america/phoenix", "america/port-au-prince", "america/port_of_spain", "america/porto_acre", "america/porto_velho", "america/puerto_rico", "america/rainy_river", "america/rankin_inlet", "america/recife", "america/regina", "america/resolute", "america/rio_branco", "america/rosario", "america/santarem", "america/santiago", "america/santo_domingo", "america/sao_paulo", "america/scoresbysund", "america/shiprock", "america/st_barthelemy", "america/st_johns", "america/st_kitts", "america/st_lucia", "america/st_thomas", "america/st_vincent", "america/swift_current", "america/tegucigalpa", "america/thule", "america/thunder_bay", "america/tijuana", "america/toronto", "america/tortola", "america/vancouver", "america/virgin", "america/whitehorse", "america/winnipeg", "america/yakutat", "america/yellowknife", "antarctica/casey", "antarctica/davis", "antarctica/dumontdurville", "antarctica/mawson", "antarctica/mcmurdo", "antarctica/palmer", "antarctica/rothera", "antarctica/south_pole", "antarctica/syowa", "antarctica/vostok", "arctic/longyearbyen", "asia/aden", "asia/almaty", "asia/amman", "asia/anadyr", "asia/aqtau", "asia/aqtobe", "asia/ashgabat", "asia/ashkhabad", "asia/baghdad", "asia/bahrain", "asia/baku", "asia/bangkok", "asia/beirut", "asia/bishkek", "asia/brunei", "asia/calcutta", "asia/choibalsan", "asia/chongqing", "asia/chungking", "asia/colombo", "asia/dacca", "asia/damascus", "asia/dhaka", "asia/dili", "asia/dubai", "asia/dushanbe", "asia/gaza", "asia/harbin", "asia/ho_chi_minh", "asia/hong_kong", "asia/hovd", "asia/irkutsk", "asia/istanbul", "asia/jakarta", "asia/jayapura", "asia/jerusalem", "asia/kabul", "asia/kamchatka", "asia/karachi", "asia/kashgar", "asia/kathmandu", "asia/katmandu", "asia/kolkata", "asia/krasnoyarsk", "asia/kuala_lumpur", "asia/kuching", "asia/kuwait", "asia/macao", "asia/macau", "asia/magadan", "asia/makassar", "asia/manila", "asia/muscat", "asia/nicosia", "asia/novosibirsk", "asia/omsk", "asia/oral", "asia/phnom_penh", "asia/pontianak", "asia/pyongyang", "asia/qatar", "asia/qyzylorda", "asia/rangoon", "asia/riyadh", "asia/riyadh87", "asia/riyadh88", "asia/riyadh89", "asia/saigon", "asia/sakhalin", "asia/samarkand", "asia/seoul", "asia/shanghai", "asia/singapore", "asia/taipei", "asia/tashkent", "asia/tbilisi", "asia/tehran", "asia/tel_aviv", "asia/thimbu", "asia/thimphu", "asia/tokyo", "asia/ujung_pandang", "asia/ulaanbaatar", "asia/ulan_bator", "asia/urumqi", "asia/vientiane", "asia/vladivostok", "asia/yakutsk", "asia/yekaterinburg", "asia/yerevan", "atlantic/azores", "atlantic/bermuda", "atlantic/canary", "atlantic/cape_verde", "atlantic/faeroe", "atlantic/faroe", "atlantic/jan_mayen", "atlantic/madeira", "atlantic/reykjavik", "atlantic/south_georgia", "atlantic/st_helena", "atlantic/stanley", "australia/act", "australia/adelaide", "australia/brisbane", "australia/broken_hill", "australia/canberra", "australia/currie", "australia/darwin", "australia/eucla", "australia/hobart", "australia/lhi", "australia/lindeman", "australia/lord_howe", "australia/melbourne", "australia/nsw", "australia/north", "australia/perth", "australia/queensland", "australia/south", "australia/sydney", "australia/tasmania", "australia/victoria", "australia/west", "australia/yancowinna", "bet", "bst", "brazil/acre", "brazil/denoronha", "brazil/east", "brazil/west", "cat", "cet", "cnt", "cst", "cst6cdt", "ctt", "canada/atlantic", "canada/central", "canada/east-saskatchewan", "canada/eastern", "canada/mountain", "canada/newfoundland", "canada/pacific", "canada/saskatchewan", "canada/yukon", "chile/continental", "chile/easterisland", "cuba", "eat", "ect", "eet", "est", "est5edt", "egypt", "eire", "etc/gmt", "etc/gmt+0", "etc/gmt+1", "etc/gmt+10", "etc/gmt+11", "etc/gmt+12", "etc/gmt+2", "etc/gmt+3", "etc/gmt+4", "etc/gmt+5", "etc/gmt+6", "etc/gmt+7", "etc/gmt+8", "etc/gmt+9", "etc/gmt-0", "etc/gmt-1", "etc/gmt-10", "etc/gmt-11", "etc/gmt-12", "etc/gmt-13", "etc/gmt-14", "etc/gmt-2", "etc/gmt-3", "etc/gmt-4", "etc/gmt-5", "etc/gmt-6", "etc/gmt-7", "etc/gmt-8", "etc/gmt-9", "etc/gmt0", "etc/greenwich", "etc/uct", "etc/utc", "etc/universal", "etc/zulu", "europe/amsterdam", "europe/andorra", "europe/athens", "europe/belfast", "europe/belgrade", "europe/berlin", "europe/bratislava", "europe/brussels", "europe/bucharest", "europe/budapest", "europe/chisinau", "europe/copenhagen", "europe/dublin", "europe/gibraltar", "europe/guernsey", "europe/helsinki", "europe/isle_of_man", "europe/istanbul", "europe/jersey", "europe/kaliningrad", "europe/kiev", "europe/lisbon", "europe/ljubljana", "europe/london", "europe/luxembourg", "europe/madrid", "europe/malta", "europe/mariehamn", "europe/minsk", "europe/monaco", "europe/moscow", "europe/nicosia", "europe/oslo", "europe/paris", "europe/podgorica", "europe/prague", "europe/riga", "europe/rome", "europe/samara", "europe/san_marino", "europe/sarajevo", "europe/simferopol", "europe/skopje", "europe/sofia", "europe/stockholm", "europe/tallinn", "europe/tirane", "europe/tiraspol", "europe/uzhgorod", "europe/vaduz", "europe/vatican", "europe/vienna", "europe/vilnius", "europe/volgograd", "europe/warsaw", "europe/zagreb", "europe/zaporozhye", "europe/zurich", "gb", "gb-eire", "gmt", "gmt0", "greenwich", "hst", "hongkong", "iet", "ist", "iceland", "indian/antananarivo", "indian/chagos", "indian/christmas", "indian/cocos", "indian/comoro", "indian/kerguelen", "indian/mahe", "indian/maldives", "indian/mauritius", "indian/mayotte", "indian/reunion", "iran", "israel", "jst", "jamaica", "japan", "kwajalein", "libya", "met", "mit", "mst", "mst7mdt", "mexico/bajanorte", "mexico/bajasur", "mexico/general", "mideast/riyadh87", "mideast/riyadh88", "mideast/riyadh89", "net", "nst", "nz", "nz-chat", "navajo", "plt", "pnt", "prc", "prt", "pst", "pst8pdt", "pacific/apia", "pacific/auckland", "pacific/chatham", "pacific/easter", "pacific/efate", "pacific/enderbury", "pacific/fakaofo", "pacific/fiji", "pacific/funafuti", "pacific/galapagos", "pacific/gambier", "pacific/guadalcanal", "pacific/guam", "pacific/honolulu", "pacific/johnston", "pacific/kiritimati", "pacific/kosrae", "pacific/kwajalein", "pacific/majuro", "pacific/marquesas", "pacific/midway", "pacific/nauru", "pacific/niue", "pacific/norfolk", "pacific/noumea", "pacific/pago_pago", "pacific/palau", "pacific/pitcairn", "pacific/ponape", "pacific/port_moresby", "pacific/rarotonga", "pacific/saipan", "pacific/samoa", "pacific/tahiti", "pacific/tarawa", "pacific/tongatapu", "pacific/truk", "pacific/wake", "pacific/wallis", "pacific/yap", "poland", "portugal", "rok", "sst", "singapore", "systemv/ast4", "systemv/ast4adt", "systemv/cst6", "systemv/cst6cdt", "systemv/est5", "systemv/est5edt", "systemv/hst10", "systemv/mst7", "systemv/mst7mdt", "systemv/pst8", "systemv/pst8pdt", "systemv/yst9", "systemv/yst9ydt", "turkey", "uct", "us/alaska", "us/aleutian", "us/arizona", "us/central", "us/east-indiana", "us/eastern", "us/hawaii", "us/indiana-starke", "us/michigan", "us/mountain", "us/pacific", "us/pacific-new", "us/samoa", "utc", "universal", "vst", "w-su", "wet", "zulu")

get-defined-tz/0

description:
Returns the names of time zones currently defined in the system. Time zones are defined by builtin functions fn:set-tz/2 and fn:set-tz/11. UTC is the only predefined zone.
format:
fn:get-defined-tz()
type:
Element-wise
examples:
fn:get-default-tz(); # = ("utc"); - if UTC is the defined time zone

set-default-tz/1

description:
Sets the default time zone.
format:
fn:set-default-tz(default as xsd:string)
type:
Static
examples:
fn:set-default-tz("africa/tunis"); # = ("africa/tunis") ; now we are in Tunis

set-tz/11

description:
defines the time zone in the system with the specified daylight offset,
format:
fn:set-tz(tz-id as xsd:string, offset as xsd:integer, daylight-start-month, daylignt-start-date, daylight-start-day, daylight-start-time, daylight-end-month, daylignt-end-date, daylight-end-day, daylight-end-time, summer-offset)
type:
Static
examples:
fn:set-tz("asia/irkutsk", 3600000*8, "mar", "last", "sun", 3600000*2, "oct", "last", "sun", 3600000*2, 3600000*1); # 380:: = ("asia/irkutsk") ; new time zone with daylight time

set-tz/2

description:
Defines the new time zone in the system with the specified shift from the UTC time.
format:
fn:set-tz(zone-name as xsd:string, time-shift as xsd:integer)
type:
Static
examples:
fn:set-tz("europe/moscow", h()*3); # = ("europe/moscow") ; new time zone without daylight time

6 Input/output function

bin-add/3

description:
Insterts the binary contents of the source indicated by url (URL or a file name) represented in the Base64 format as the idx-th value of object's dmap/string property prop,
format:
object / fn:bin-add(`prop, idx, url);
type:
Element-wise
examples:
&object / fn:bin-add(`image, 0, "http://meta2project.org/en/libretto/dot.gif");

bin-export/3

description:
Exports the base64binary from idx-th element of dmap/string t-property of object to new file filename
format:
object / fn:bin-export(`prop, idx, filename)
type:
Element-wise
examples:
&a/fn:bin-export(`image, 0, "dd.gif");

bin-set/3

description:
Replaces the idx-th value of object's dmap/string property prop by the binary contents of the source indicated by url (URL or a file name) represented in the Base64 format,
format:
object / fn:bin-set(`prop, idx, url)
type:
Element-wise
examples:
&a / fn:bin-set(`image, 0, "http://meta2project.org/en/libretto/dot.gif")

box2mvx/1

description:
Saves the current state of the ontobase in the binary (zipped XML) MVX format in the file 'filename'.
format:
fn:box2mvx(filename as xsd:string)
type:
Static

mvx2box/1

description:
Load the contents of the MVX file filename.mvx (an ontobase dump file) in the OntoBox.
format:
fn:mvx2box("filename.mvx")
type:
Static

print/0

description:
Prints the context value in stdout stream. Returns the input value.
format:
[.] print() as Value
type:
Element-wise

println/0

description:
Prints the context value in stdout stream with finishing new line. Returns the input value.
format:
println() as Value
type:
Element-wise

read/1

description:
Reads a string from the file
format:
fn:read(filename as String) as String
type:
Static

read-html/3

description:
Reads an html document from the file or URL filename with the specified character encoding. ontology-id is the ontology identifier in whih the objects of this xml document to be stroed. Can be presented by either a quoted expression like `p* or the ontology prefix like "p", or the ontology URI like "http://aaa". The prefix can start with '@', e.g. "@p", and this means that if an ontology with the prefix "p", then it must be created with some surrogate URI
format:
fn:read-html(filename, ontology-id, charset)
type:
Static
examples:
fn:read-html("http://ontobox.org", "w", "utf-8");

read-html-string/1

description:
Converts an html document represented by a context string into a set of objects stored in the ontology ontology-id. ontology-id is the ontology identifier in whih the objects of this xml document to be stroed. Can be presented by either a quoted expression like `p* or the ontology prefix like "p", or the ontology URI like "http://aaa". The prefix can start with '@', e.g. "@p", and this means that if an ontology with the prefix "p", then it must be created with some surrogate URI
format:
html-string / fn:read-html-string(ontology-id)
type:
Element-wise

read-lines/2

description:
The same as read-line/1 but with explicit encoding parameter as the 2nd argument. Its possible values are "utf-8", "windows-1251" etc.
format:
fn:read-lines(url as Filename or URL, encd as String) as Sequence of String
type:
Static
examples:
fn:read-lines("http://rbc.ru", "windows-1251");

read-lines/1

description:
Lazily generates the sequence of strings from a textual source indicated by its URL or filename (parameter url).
format:
fn:read-lines(url as Filename or URL) as Sequence of String
type:
Static
examples:
fn:read-lines("http://www.cnn.com") / fn:Count(); # = (1320) counts the number of lines in cnn.com

read-xml/2

description:
Reads an XML file from a file/http. xmlfilename - the name of file or URL ontology-id is the ontology identifier in whih the objects of this xml document to be stroed. Can be presented by either a quoted expression like `p* or the ontology prefix like "p", or the ontology URI like "http://aaa". The prefix can start with '@', e.g. "@p", and this means that if an ontology with the prefix "p", then it must be created with some surrogate URI,
format:
fn:read-xml(xmlfilename, ontology-id)
type:
Static

read-xml-string/1

description:
Imports the XML document from the string xmlstring to the set of xml-objects stored in the ontology ontology-id. ontology-id is the ontology identifier in whih the objects of this xml document to be stroed. Can be presented by either a quoted expression like `p* or the ontology prefix like "p", or the ontology URI like "http://aaa". The prefix can start with '@', e.g. "@p", and this means that if an ontology with the prefix "p", then it must be created with some surrogate URI,
format:
xmlstring / fn:read-xml-string(ontology-id)
type:
Element-wise

text-add/4

description:
Adds a new value of the dmap/string object's property prop at position idx. The value is the content of source url read in encoding encd.
format:
object / fn:text-add(`prop, idx, url, encd)
type:
Element-wise
examples:
&a / fn:text-add(`text, -2, "wi.txt", "windows-1251");

text-add/3

description:
Adds a new value of the dmap/string object's property prop at position idx. The value is the content of source url read in the default encoding UTF-8.
format:
object / fn:text-add(`prop, idx, url)
type:
Element-wise
examples:
&a / fn:text-add(`text, -2, "uj.txt");

text-export/4

description:
Exports the idx-th value of the object's property prop to the file url in the text encoding format encd.
format:
object / fn:text-export(`prop, idx, url, encd)
type:
Element-wise
examples:
&a / fn:text-export(`text, 0, "tmp.txt", "windows-1251");

text-export/3

description:
Exports the idx-th value of the object's property prop to the file url in the default text encoding format UTF-8.
format:
object / fn:text-export(`prop, idx, url)
type:
Element-wise
examples:
&a / fn:text-export(`text, 0, "tmp.txt");

text-set/4

description:
Replaces the idx-th value of the dmap/string object's property prop by the content of source url read in the encoding encd.
format:
object / fn:text-set(`prop, idx, url, encd)
type:
Element-wise
examples:
&a / fn:text-set(`text, 0, "ui.txt", "windows-1251");

text-set/3

description:
Replaces the idx-th value of the dmap/string object's property prop by the content of source url read in the default encoding.
format:
object / fn:text-set(`prop, idx, url)
type:
Element-wise
examples:
&a / fn:text-set(`text, 0, "ui.txt");

write/2

description:
Writes the output to the new file
format:
fn:write(filename as xsd:string, output as Value)
type:
Static

write-xml/2

description:
Saves the XML document stored in the ontobase with the root root-object to the file named xmlfilename
format:
fn:write-xml(xmlfilename, root-object);
type:
Static

write-xml-string/1

description:
Converts the XML document with the root root-object into a string.
format:
fn:write-xml-string(root-object);
type:
Static

7 Type Function

is-integer/0

description:
Checks if the context element is integer
format:
is-integer()
type:
Element-wise

is-map/0

description:
Checks if the context element is map
format:
&obj / fn:is-map()
type:
Element-wise

is-string/0

description:
Checks if the context element is string
format:
is-string()
type:
Element-wise

is-temp/0

description:
Checks if the context element is a temporary object.
format:
Value / fn:is-temp()
type:
Element-wise

8 Ontobox model function

add-subclass/1

description:
Declares the class (represented as a quoted exp in the 1st argument) as the subclass of the context quoted class.
format:
[`Cls1] add-subclass(`Cls2);
type:
Element-wise

add-to-class/1

description:
Adds the context object to the class (1st argument) represented as a quoted expression.
format:
&obj/fn:add-to-class(`Class) as &obj
type:
Element-wise

annotate/2

description:
Sets annotation named key and valued value to the current context object. If key and value are collections then sets as annotations the pairs key[i]/value[i].
format:
[`ont* | `C | `&obj | &obj] annotate(key as xsd:string*, value as xsd:string*);
type:
Element-wise

apply-property/1

description:
Applies the property to the input object.
format:
apply-property(prop as quoted exp or uri)
type:
Element-wise
examples:
&p:tom/apply-property("http://teacode.com/people#salary"); # = (200, 300, 400)
*[apply-property("http://teacode.com/people#salary")]; # = (tom)
&p:tom/apply-property("http://teacode.com/people#hasChild"); # = (tim)
*[apply-property("http://teacode.com/people#hasChild") = &p:tom]; # = (john, ann)

box2libretto/0

description:
Translates the contents of the ontobase as a code in Libretto. Returns the result as a string.
format:
fn:box2libretto() as xsd:string
type:
Static

create-class/1

description:
Creates a new class in the ontology represented by the context value. The argument name is the short name of the new class within the ontology.
format:
[`ont*] create-class(name as xsd:string);
type:
Element-wise

create-obj/2

description:
Creates an object of the class Class (1st arg) in the ontology `ont* (2nd arg).
format:
fn:create-obj(`Class, `ont*);
type:
Static

create-obj/1

description:
Creates an amonimous object in the class represented in the 1st argument by a quoted expression.
format:
fn:create-obj(`Class)
type:
Static

create-object/1

description:
Creates an object in the context ontology.
format:
(`ont*)/fn:create-object(name as xsd:string)
type:
Element-wise

create-oprop/3

description:
Creates in ontology 'ont' a new o-property named 'oprop-name' with the domain Class1 and range Class2. Returns the quoted o-proprety.
format:
(`ont*)/fn:create-oprop(oprop-name as xsd:sting, `Class1 as Quoted, `Class2 as Quoted) as Quoted;
type:
Element-wise

delete/0

description:
Removes from the Ontobox the ontology or entity. This operation succeeds only if no other entity stored in the Ontobox depends on the deleted entity.
format:
[`ont* | `Cls | &obj | `&obj | `prop] delete();
type:
Element-wise

entity-kind/0

description:
If the context string is a full entity name or a quoted expression, the function returns the kind of this entity. The options are "ONTCLASS", "ONTOBJECT", "TPROPERTY", "OPPROPERTY", "ONTOLOGY", "TYPE". Returns () otherwise.
format:
entity-kind() as Boolean
type:
Element-wise

force-delete/0

description:
Deletes the context object with removing all property links to the deleted object.
format:
&obj / fn:force-delete()
type:
Element-wise

get-all-classes/0

description:
Gets all classes defined in the ontology represented by the context value.
format:
[`ont*] get-all-classes();
type:
Element-wise

get-all-oprops/0

description:
Gets all o-properties of the ontology or entity in the context.
format:
[`ont* | `Cls | `&obj | &obj] get-all-oprops();
type:
Element-wise

get-all-subclasses/0

description:
Get all subclasses (direct and indirect) of the quoted class in the context.
format:
[`Cls] get-all-subclasses();
type:
Element-wise

get-all-superclasses/0

description:
Gets all superclasses (direct and indirect) of the quoted class in the context.
format:
[`Cls] get-all-superclasses();
type:
Element-wise

get-all-tprops/0

description:
Gets all t-properties of the ontology or entity in the context.
format:
[`ont* | `Cls | `&obj | &obj] get-all-tprops();
type:
Element-wise

get-annotation/1

description:
Returns the value of the annotation named key assigned to the context object.
format:
[`ont* | `C | `&obj | &obj] get-annotation(key as xsd:string);
type:
Element-wise

get-annotation-names/0

description:
Returns all annotation keys linked to the context value as an annotated entity,
format:
AnnotatedValue/fn:get-annotation-names();
type:
Element-wise

get-direct-objects/0

description:
Gets all direct objects of the quoted class in the context (i.e. those explicitly defined in the class).
format:
[`Cls] get-direct-objects();
type:
Element-wise

get-direct-oprops/0

description:
Get direct o-properties of the class (i.e. for which the class is declared as their domain).
format:
[`Cls] get-direct-oprops();
type:
Element-wise

get-direct-subclasses/0

description:
Get direct superclasses of the class (i.e. those for which the current class is explicitly declared as their superclass).
format:
[`Cls] get-direct-subclasses();
type:
Element-wise

get-direct-superclasses/0

description:
Get direct superclasses of the class (i.e. those for which the current class is explicitly declared as their subclass).
format:
[`Cls] get-direct-superclasses();
type:
Element-wise

get-direct-tprops/0

description:
Get direct t-properties of the class (i.e. for which the class is declared as their domain).
format:
[`Cls] get-direct-tprops();
type:
Element-wise

get-domain/0

description:
Gets the domain class of the property.
format:
[`prop] get-domain();
type:
Element-wise

get-entity-by-name/0

description:
Gets the entity in the ontobase corresponding to the full name (URI) represented by the context string.
format:
[xsd:string] get-entity-by-name();
type:
Element-wise

get-local/0

description:
returns the local name of the context entity in the ontology. The entity can be represented by its URI or as a quoted term.
format:
quoted-entity / fn:get-local() as xsd:string
type:
Element-wise
examples:
(`A) /fn:get-local(); # = ("A")

get-max-card/0

description:
Gets max cardinality of the property (default value: infinity denoted by -1).
format:
[`prop] get-max-card();
type:
Element-wise

get-min-card/0

description:
Gets min cardinality of the property (default value: 0).
format:
[`prop] get-min-card();
type:
Element-wise

get-name/0

description:
Gets the full name (URI) of the ontobase entity represented by the context value.
format:
[`Cls | &obj | `&obj | `prop] get-name();
type:
Element-wise

get-object-classes/0

description:
Returns the direct classes of the context object as quoted expressions.
format:
&obj / fn:get-object-classes() as Quoted classes
type:
Element-wise

get-object-props/0

description:
Returns all properties relevant to the context object
format:
&obj /fn:get-object-props() as Quoted properties
type:
Element-wise

get-ontologies/0

description:
returns the sequence of URIs of the ontologies stored in the ontobase.
format:
fn:get-ontologies() as Sequence of URI
type:
Static
examples:
fn:get-ontologies(); # = ("http://ontobox.org/libretto/builtins", "http://www.w3.org/2001/XMLSchema", "http://ontobox.org/", "http://www.ontobox.org/libretto/embedded/xml", "http://ontobox.org/map")

get-ontology/0

description:
Gets the ontology in which the Ontobox entity represented by the context value is defined.
format:
[`Cls | &obj | `&obj | `prop] get-ontology();
type:
Element-wise

get-ontology-by-prefix/0

description:
finds the ontology by the prefix (the context value). The ontology is returned in the form of a quoted expression.
format:
Prefix-string / fn:get-ontology-by-prefix() as Quoted
type:
Element-wise
examples:
"map" / fn:get-ontology-by-prefix(); # = (`map*)

get-ontology-map/0

description:
returns the mapping from ontology prefixes to ontology URIs as a sequence of map-objects with keys "prefix" and "name", e.g. &{:prefix := "map", name := "http://ontobox.org/map"} Since 'prefix' is a keyword, it must be used here with ':', e.g. :prefix.
format:
fn:get-ontology-map()
type:
Static
examples:
fn:get-ontology-map()/'"{:prefix}" -> {name}'; # = ("" -> http://temp.ontobox.org/2010-03-21/22-53, "map" -> http://ontobox.org/map, "xsd" -> http://www.w3.org/2001/XMLSchema, "box" -> http://ontobox.org/, "fn" -> http://ontobox.org/libretto/builtins, "x" -> http://www.ontobox.org/libretto/embedded/xml)

get-owners/0

description:
Returns all objects which have the context object as the value of one of their properties.
format:
&obj / fn:get-owners()
type:
Element-wise

get-prefix/0

description:
Returns the prefix of the ontology (the context value). The ontology can be represented as a quoted expression or by the URI
format:
ontology as quoted/xsd:string / fn:get-prefix() as xsd:string
type:
Element-wise
examples:
"http://ontobox.org/" / fn:get-prefix(); # = ("box")

get-range/0

description:
Gets the range of the property (a class in case of o-properties and datatype in case of t-properties).
format:
[`prop] get-range();
type:
Element-wise

is-subclass-of/1

description:
True if the context class is the (direct or indirect) subclass of the class in the argument.
format:
[`Cls1] is-subclass-of(`Cls2);
type:
Element-wise

ontology/2

description:
Creates a new ontology named uri and assigns the prefix to it. If an ontology with the name uri exists, the function only assigns the prefix,
format:
fn:ontology(prefix as xsd:string, uri as xsd:string) as quoted
type:
Static
examples:
fn:ontology("he", "http://hehe/"); # = (`he*)

prefix/2

description:
Assigns the prefix to the existing ontology.
format:
fn:prefix(new-prefix as xsd:string, prefix-or-uri as xsd:string) as quoted
type:
Static
examples:
fn:ontology("he", "http://hehe/"); # = (`he*)

remove-from-class/1

description:
Removes the context object from the class (represented as a quoted expression in the 1st argument).
format:
&obj/fn:remove-from-class(`Class)
type:
Element-wise

set-local/1

description:
Sets the new local name of the ontobase entity represented by the context value.
format:
[&obj | `Cls | `&obj | `prop] set-local(name as xsd:string);
type:
Element-wise

set-obj-id/2

description:
Sets the new name (2nd arg) to the object (1st arg).
format:
fn:set-obj-id(&obj, "newname")
type:
Static

set-ontology-name/1

description:
Assigns a new name (URI) to the ontology.
format:
[`ont*] set-ontology-name(URI as xsd:string)
type:
Element-wise

tbox2libretto/0

description:
Translates the terminological data of the ontobase (without objects) into a Libretto program. Returns a string with the Libretto code.
format:
fn:tbox2libretto() as xsd:string
type:
Static

9 Map Function

get-key-value/1

description:
format:
get-key-value(key as String)
type:
Element-wise

get-okeys/0

description:
Returns the sequence of the o-keys of the context map
format:
&obj / fn:get-okeys()
type:
Element-wise

get-tkeys/0

description:
Returns the sequence of the t-keys of the context map
format:
get-tkeys()
type:
Element-wise

key-remove/1

description:
Removes the key with its values from the context map element
format:
Sequence of Map / key-remove(key as String) as String
type:
Element-wise

key-set/2

description:
Sets new values to the key of the context map element, removing previous values (if there any).
format:
Sequence of Map / key-set(key as String, value as Object) as String
type:
Element-wise

10 Meta function

delete-index/1

description:
removes the index indicated by the 1st argument from the table of indexes.
format:
fn:delete-index("indexname");
type:
Static

eval/0

description:
Evaluates an (absolute) quoted expression from the context.
format:
`expr / fn:eval()
type:
Element-wise
examples:
(`1+2) / fn:eval(); # = (3)

eval/1

description:
In Libretto it is possible to block the evaluation of a term by putting "`" before it. In this case the path term becomes an ordinary datum. For evaluation of the suspended expression, the function eval/1 is used. To evaluate in the context of C, we write C/evaluate(pt). fn:eval/1 also can evaluate string queries.
format:
eval(pt as Term|String) as Collection
type:
Element-wise
examples:
$term := `. + 1; (1, 2)/eval($term); # = (2, 3)
fn:eval("1+2;"); #2 = (3)

execute/0

description:
Executes the libretto program from the context, and produces a temporary map with two keys - 'query' for quoted expression for the query and 'answer' for the result of this query. && {query := `1+2; answer := 3} The maps in the output sequence are ordered as queries in the input program.
format:
Code as xsd:string / fn:execute() as sequence of temp-key-value-maps
type:
Element-wise
examples:
("function f($x) $x + 1; f(5)+6;") / fn:execute() / ("query = {query} answer = {answer}"); #2 = (query = `function f($x) $x + 1; answer = "", query = `f(5) + 6; answer = 12)

get-index/2

description:
Gets a value of the key in the 'reverse' hash table named 'hash-name'. E.g. if we want to have fast access from people to their grandparent, we can create the hash table: fn:set-index("gps", `Person, `child/child); then to get John's grandparent we write fn:get-index("gps", &John) That is, this function creates reverse mapping from the result values of some query to the values of its initial context sequence. "gps" is the identifier of this map
format:
fn:get-index(hash-name as xsd:string, key as Value)
type:
Static

get-index-keys/1

description:
returns the keys of the index named index-id and generated by set-index/2.
format:
fn:get-index-keys(index-id as xsd:string) as sequence of index keys
type:
Static
examples:
fn:get-index-keys("lines") / fn:Count(); # = (37)

load/1

description:
Loads (evaluates) a Libretto script from the file named librettofilename.
format:
fn:load( librettofilename );
type:
Static

remove-index-key/1

description:
removes the key "indexkeyname" from the index "indexname".
format:
"indexkeyname" / fn:remove-index-key("indexname");
type:
Element-wise
examples:
("make", "better") / fn:remove-index-key("line-index");

set-index/4

description:
Creates an index (vocabulary) named 'index-name' aimed at fast access to a value ("description") by its key ("term"). E.g. if we want to have fast access from people to their grandparent, we can create the index: fn:set-index("gps", Person, `., `child/child); Now to get John's grandparent we write fn:get-index("gps", &John) The 1st argument is the index's name The 2nd argument is the basic set of elements for indexing The 3rd argument is the expression for calculating the indexed value corresponding to the current basic element The 4th argument is the expression for calculating the indexing value corresponding to the current basic element In the example for each person &p the constructed index maps each value of &p/(child/child) to &p/(.)
format:
fn:set-index(index-name as xsd:string, domain as Sequence, indexed-el as Quoted, indexing-val as Quoted)
type:
Static

stop/0

description:
Stops in a normal way the execution of a Libretto script,
format:
fn:stop()
type:
Static

11 Aux

exit/1

description:
Halts the computation and quits the interpreter with code 'code'.
format:
fn:exit(code as xsd:integer)
type:
Static

generate-prefixes/0

description:
Automatically assigns prefixes to unprefixed ontologies in the ontobase.
format:
fn:generate-prefixes()
type:
Static

get-modified/0

description:
Returns the value of the modified object within the modifier. Depricated because can be substituted by fields ('as' + variables).
format:
fn:get-modified()
type:
Static

void/1

description:
Returns its argument.
format:
fn:void(val as Value)
type:
Static