addFunction/1
- description:
Adds a new user-defined function. For instance,
addFunction("def add1() {. + 1}");
introduces function add1/0. Returns the internal function number.
- format:
void addFunction($funcode string) int (internal function number)
- type:
- Static
addObjectClass/1
- description:
Adds the context object to the class (1st argument).
- format:
object addObjectClass($cls class) object
- type:
- Element-wise
addSubclass/1
- description:
Declares the class (1st argument) as the subclass of the context class.
- format:
class(sup) addSubclass($sub class)
- type:
- Element-wise
addValues/2
- description:
Adds values to the property $prop of the context object. This function behaves like +=.
- format:
object addValues($prop entity (property), $values object+) object
- type:
- Element-wise
addValues/3
- description:
Inserts new values to the values of the property $prop at position $index of the context object.
- format:
object addValues($prop entity (property), $values object+, $index int) object
- type:
- Element-wise
annames/0
- description:
Returns all annotation keys linked to the context value as an annotated entity,
- format:
{entity, string} annames() string
- type:
- Element-wise
anno/1
- description:
Returns the value of the annotation $key assigned to the context object.
- format:
{string, entity} anno($key string) string
- 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 it sets as annotations the pairs $key[i]/$value[i]. Returns the annotated entity itself.
- format:
{entity, string} annotate($key string*, $value string*) {entity, string}
- type:
- Element-wise
classesDirect/0
- description:
Returns direct superclasses of the class (i.e. those from which the current class directly inherits), direct classes of objects, or 'senior' classes of the ontologies.
- format:
{ontology, class, object} classesDirect() class
- type:
- Element-wise
classes/0
- description:
Gets all classes for the entity (ontology, class or object).
- format:
{ontology, class, object} classes() class
- type:
- Element-wise
clone/1
- description:
Copies the context object into the other ontology $onto (creates a new anonymous element with the same parameters). The links to the input object are not moved.
- format:
object clone($onto ontology) object(new)
- type:
- Element-wise
deleteForced/0
- description:
Deletes the context object with removing all property links to the deleted object.
- format:
object deleteForced()
- type:
- Element-wise
delete/0
- description:
Removes the context entity from the box. This operation succeeds only if no other entity from the box depends on the deleted entity.
- format:
entity delete()
- type:
- Element-wise
domain/0
- description:
Gets the domain class of the property.
- format:
{tproperty, oproperty} domain() class
- type:
- Element-wise
entity/0
- description:
Returns the entity in the box corresponding to the full name (URI) from the context. Returns nothing if such entity does not exist.
- format:
string entity() entity
- type:
- Element-wise
entity/1
- description:
Returns the entity with the local name in the context belonging to the ontology $ont. Returns nothing otherwise.
- format:
string entity($ont ontology) entity
generatePrefixes/0
- description:
Automatically assigns prefixes to unprefixed ontologies in the box. Returns the list of prefixes as strings.
- format:
void generatePrefixes() string*
- type:
- Static
get/1
- description:
Returns the value of the key (annotation) $keyname of the context object (entity).
- format:
object|entity get($keyname string) string +
- type:
- Element-wise
instanceof/1
- description:
Lets the object through if it is the instance of the class in the function argument.
- format:
object instanceof($cls class) object
- type:
- Element-wise
keys/0
- description:
Returns the names of object's keys, if the context value is an object; returns the names of entities, if the context value is an entity.
- format:
object|entity keys() string +
- type:
- Element-wise
local/0
- description:
Returns the local name of the context entity in the ontology. The entity can be represented by its URI or as an entity value.
- format:
entity local() string
- type:
- Element-wise
- examples:
`a:A / local(); # = (A)
maxCard/0
- description:
Gets max cardinality of the property - the maximum allowed number of values (default value: infinity denoted by -1).
- format:
property maxCard() int
- type:
- Element-wise
minCard/0
- description:
Gets min cardinality of the property - the minimum allowed number of values (default value: 0).
- format:
property minCard() int
- type:
- Element-wise
move/1
- description:
Moves the context object into the other ontology $onto (creates a new anonymous element with the same parameters). All links to the old object from other objects through o-properties are also moved.
- format:
object move($onto ontology) object(new)
- type:
- Element-wise
name/0
- description:
Gets the full name (URI) of the entity represented by the context value.
- format:
entity name() string
- type:
- Element-wise
newClass/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:
ontology newClass($name string) class
- type:
- Element-wise
newDate/0
- description:
Creates a new date value with the current date and time.
- format:
v:newDate() v:date
- type:
- Static
newName/0
- description:
Generate a new (unused in the ontology) surrogate full name. This name does not correspond to any ontology's entity.
- format:
ontology newName() string
- type:
- Element-wise
newName/1
- description:
Generates a new URI string made of the context ontology's URI and local name in the argument. The state of the name is not checked.
- format:
ontology newName($local string) string
- type:
- Element-wise
newObject/1
- description:
Creates an anomymous object in the ontology indicated in the 1st argument. To give the object a name, use rename/1.
- format:
ontology newObject() object
- type:
- Static
newOntology/1
- description:
Creates a new ontology and assigns the prefix to it. If an ontology with the name exists, the function only assigns the prefix.
- format:
string newOntology($prefix string) ontology
- type:
- Static
- examples:
"http://hehe" / newOntology("he"); # = (`he:*)
newOprop/1
- description:
Creates in the context ontology a new o-property named $oprop-name. Returns the new o-proprety.
- format:
ontology newOprop($oprop-name sting) oproperty
- type:
- Element-wise
newTprop/1
- description:
Creates a new t-property named $tprop-name in the context ontology. Returns the new o-proprety.
- format:
ontology newTprop($tprop-name sting) tproperty
- type:
- Element-wise
newType/1
- description:
Creates a new data type in the context ontology.
- format:
ontology newType($type-local string) type
- type:
- Element-wise
objectsDirect/0
- description:
Gets all direct objects of the quoted class in the context (i.e. those explicitly defined in the class).
- format:
class objectsDirect() object*
- type:
- Element-wise
objects/0
- description:
For objects: collects the values of all o-properties of the current context object; for ontology: collects all objects of the ontology; for oproperty: collects all existing values of the oproperty.
- format:
{ontology, oproperty, object} objects() object*
- type:
- Element-wise
ontologies/0
- description:
returns the sequence of the ontologies stored in the box.
- format:
ontologies() ontology*
- type:
- Static
- examples:
ontologies(); # = (`x:*, `xml:*, `map:*)
ontology/0
- description:
Gets the ontology, in which the context entity is defined. Also gets the ontology by its prefix / uri.
- format:
{entity, string(prefix), string(uri)} ontology() ontology
- type:
- Element-wise
opropsDirect/0
- description:
Gets direct o-properties of the class (i.e. for which the class is declared as their domain).
- format:
{ontology, class, object} opropsDirect() oproperty*
- type:
- Element-wise
oprops/0
- description:
Gets all o-properties of the ontology, class or object from the context.
- format:
{ontology, class, object} oprops() oproperty*
- type:
- Element-wise
ownersProps/0
- description:
Returns objects containing triples owner-oproperty-index
&_ {@o := [owner]; @p := [oproperty]; @i := [index] }
listing the objects @o, for which the context object or value is a value of the oproperty @p at position @i.
- format:
any ownersProps() object*
- type:
- Element-wise
owners/0
- description:
Returns objects having the context element (either object or data value) as their property value.
- format:
any owners() object*
- type:
- Element-wise
owners/1
- description:
Finds all owners of the context object (through o-properties) or data value (through t-properties). Equivalent to taking inverse property value: ~prop.
- format:
{object, value} owners($prop entity (oproperty, tproperty)) object*
- type:
- Element-wise
prefix/0
- description:
Returns the prefix of the ontology (the context value). The ontology can be represented as an entity (quoted expression) or by the URI. If the prefix does not exist nothing is returned.
- format:
{ontology, string(uri)} / prefix() string
- type:
- Element-wise
- examples:
"http://ontobox.org/" / prefix(); # = ("v")
prefix/1
- description:
Assigns the prefix to the existing ontology.
- format:
{string(prefix), string(uri), ontology} prefix($new-prefix string) ontology
- type:
- Static
- examples:
"http://hehe" / prefix("he"); # = (`he:*)
prefixes/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"}
- format:
void prefixes() map:Map
- type:
- Static
- examples:
prefixes()/'"{@prefix}" -> {@name}'!; # = ("v" -> http://ontobox.org/ "p" -> http://a "map" -> http://ontobox.org/map, "x" -> http://xml.ontobox.org/)
props/0
- description:
Returns all properties relevant to the context entity or ontology
- format:
{ontology, class, object} props() property*
- type:
- Element-wise
put/2
- description:
Sets new values to the key of the context object, removing previous values (if there any).
- format:
object put($key string, $value any) string
- type:
- Element-wise
- examples:
$object := &_ / v:put("num", 1);
$object / @num; # = (1)
range/0
- description:
Returns the range of the property (a class in case of o-properties and datatype in case of t-properties).
- format:
{oproperty, tproperty} range() {class, type}
- type:
- Element-wise
removeKey/1
- description:
Removes the key with its values from the context map element
- format:
map:Map removeKey($key string) map:Map
- type:
- Element-wise
removeObjectClass/1
- description:
Removes the context object from the class.
- format:
object removeObjectClass($cls class) object
- type:
- Element-wise
removeSubclass/1
- description:
Removes subclass (1st argument) from the superclass from the context (change class hierarchy). Returns the context superclass.
- format:
class(sup) removeSubclass($subclass class) class(sup)
- type:
- Element-wise
removeValue/2
- description:
Removes value with specified index.
- format:
object removeValue($prop property, $idx int) object
- type:
- Element-wise
removeValues/0
- description:
Removes in object all values of all properties.
- format:
object removeValues() object
- type:
- Element-wise
removeValues/1
- description:
Removes all values of the property.
- format:
object removeValues($prop property) object
- type:
- Element-wise
remove-values/2
- description:
Removes those values of the property $prop of the context object, for which the condition ./$cond! is true (not empty).
- format:
object removeValues($prop property, $cond expr) object
- type:
- Element-wise
- examples:
class C(v C);
C &c, &c1, &c2, &c3, &c4;
&c {v := (&c1, &c2, &c3, &c4)};
&c / v:removeValues(%v, _{. = &c3 or . = &c1});
&c / v; # = (&c2, &c4)
rename/1
- description:
Sets the new local name of the context entity, including ontologies.
- format:
entity rename($local string) entity
- type:
- Element-wise
replaceValues/3
- description:
Substitutes in the context object the values of property $prop by the values obtained by ./$newval!. This expression is evaluated with the replaced value as the context element.
- format:
object replaceValues($prop property, $cond expr, $newval expr) object
- type:
- Element-wise
- examples:
class C(n v:int);
C &c {n := (1,2,3,4,5)};
&c / v:replaceValues(%n, _{. mod 2 = 0}, _{(., . * .)});
&c / n; # = (1, 2, 4, 3, 4, 16, 5)
setDomain/1
- format:
{tproperty, oproperty} setDomain($cls class) {tproperty, oproperty}
- type:
- Element-wise
setRange/1
- description:
Determines the range of the property.
- format:
{oproperty, tproperty} setRange($cls {class, type}) {oproperty, tproperty}
- type:
- Element-wise
setValues/2
- description:
Sets new values to the property $prop of the context object. The old values are removed.
- format:
object setValues($prop entity (property), $values any+) object
- type:
- Element-wise
short/0
- description:
returns a short name (prefix + ':' + local) of the context entity.
- format:
entity short() string
- type:
- Element-wise
string/0
- description:
Returns the string representation of the entity or data
- format:
any string() string
- type:
- Element-wise
- examples:
(1, "1", 1.2)[string()/contains(".")]; # = (1.2)
subclassesDirect/0
- description:
Returns the direct superclasses of the class from the context (i.e. those for which the current class is explicitly declared as their superclass).
- format:
class subclassesDirect() class*
- type:
- Element-wise
subclasses/0
- description:
Get all subclasses (direct and indirect) of the class from the context.
- format:
class subclasses() class*
- type:
- Element-wise
subclassof/1
- description:
Lets the context class through if it is a subclass of the function argument.
- format:
class subclassof($sup class) int
- 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:
void tbox2libretto() void
- type:
- Static
toBoolean/1
- description:
Creates a new boolean constant represented by the input string.
- format:
void toBoolean($bool-string string) boolean
- type:
- Static
toClass/0
- description:
Creates a new class entity for the existing class by the full name in the context string.
- format:
string (classname) toClass() class
- type:
- Element-wise
toClass/1
- description:
Creates a new class constant for the existing class represented in the input string.
- format:
void toClass($class-string string) class
- type:
- Static
toDate/0
- description:
Creates a new date entity represented by the context string.
- format:
string (date) toDate() date
- type:
- Element-wise
toDate/1
- description:
Creates a new date entity represented by the string in the 1st argument.
- format:
void toDate($date-string string) date
- type:
- Static
toExpr/0
- description:
Creates a new Libretto expression entity represented by the context string.
- format:
string (expr) toExpr() expr
- type:
- Element-wise
toExpr/1
- description:
Creates a new Libretto expression entity represented by the string in the 1st argument.
- format:
void toExpr($expr-string string) expr
- type:
- Static
toFloat/0
- description:
Creates a new float constant by the context string.
- format:
string (float) toFloat() expr
- type:
- Element-wise
toFloat/1
- description:
Creates a new float constant by the string in the 1st argument.
- format:
void toFloat($float-string string) expr
- type:
- Static
toFunction/0
- description:
The same as function/1 but with the input from the context.
- format:
string (function decl) toFunction() function
- type:
- Element-wise
toFunction/1
- description:
Creates a new function constant from the input string representation,
The string in $func-string must be a Libretto function definition, like
"function f($x) { $x + 1 }"
newFunction/1 translates this string in the current context of the box (with existing ontologies, class definitions, etc.) The result of this translation is the value of the datatype function. This value can be handled as values of other types, e.g. assigned to a tproperty. To male such an object a working function, the built-in eval/1 can be used, for instance:
class Libfunc {
fun function
};
Libfunc &myfunc {
fun := toFunction("function add1($x) { $x + 1 }")
};
# now load this function in the box:
eval(&myfunc/fun);
The functions declared in the box also can be used as function data values, For this, use the quote symbol "`":
function add1($x) { $x + 1 };
&myfunc {fun:= `add1};
- format:
void toFunction($func-string string) function
- type:
- Static
toInt/0
- description:
Creates a new integer constant by the context string.
- format:
string (int) toInt() int
- type:
- Element-wise
toInt/1
- description:
Creates a new integer constant by the string in the 1st argument.
- format:
void toInt($int-string string) int
- type:
- Static
toLong/0
- description:
Creates a new long integer constant by the context string.
- format:
string (long) toLong() long
- type:
- Element-wise
toLong/1
- description:
Creates a new long integer constant by the string in the 1st argument.
- format:
void toLong($long-string string) long
- type:
- Static
toOntology/0
- description:
Creates a new ontology constant for the existing ontology by the context string.
- format:
string (ontology name) toOntology() ontology
- type:
- Element-wise
toOntology/1
- description:
Creates a new ontology constant for the existing ontology by the string in the 1st argument.
- format:
void toOntology($onto-string string) ontology
- type:
- Static
toOproperty/0
- description:
Creates a new oproperty entitiy for the existing oproperty by the context string.
- format:
string (oprop name) toOproperty() oproperty
- type:
- Element-wise
toOproperty/1
- description:
Creates a new oproperty entitiy for the existing oproperty by the string in the 1st argument.
- format:
void toOproperty($oprop-string string) oproperty
- type:
- Static
toString/0
- description:
Converts the context string into a string.
- format:
any toString() string
- type:
- Element-wise
toString/1
- description:
Converts its argument into a string.
- format:
void toString($entity any) string
- type:
- Static
toTproperty/0
- description:
Creates a new tproperty entity for the existing tproperty named by the context string.
- format:
string (tprop name) toTproperty() tproperty
- type:
- Element-wise
toTproperty/1
- description:
Creates a new tproperty entity for the existing tproperty by the string in the 1st argument.
- format:
void toTproperty($tprop-string string) tproperty
- type:
- Static
toType/0
- description:
Creates a new type entity for an existing data type named by the context string.
- format:
string (type name) toType() type
- type:
- Element-wise
toType/1
- description:
Creates a new type entity for an existing data type named by the string in the 1st argument.
- format:
void toType($type-string string) type
- type:
- Static
tpropsDirect/0
- description:
Get direct t-properties of the class (i.e. for which the class is declared as their domain).
- format:
class tpropsDirect() tproperty*
- type:
- Element-wise
tprops/0
- description:
Gets all t-properties of the ontology, class or object from the context.
- format:
{ontology, class, object} tprops() tproperty*
- type:
- Element-wise
type/0
- description:
This function returns the type of the context value. If the context value is an object, the function returns the direct classes it belongs to.
- format:
any type() entity
- type:
- Element-wise
types/0
- description:
Returns all data types of the ontology.
- format:
ontology types() type*
- type:
- Element-wise
values/0
- description:
Collects all data values of the context tproperty or object.
- format:
{tproperty, object} values() datavalue
- type:
- Element-wise
values/1
- description:
Gets the property/key value of the object/map.
- format:
object values($propkey {property, string(mapkey)}) any*
- type:
- Element-wise
collect/1
- description:
Collects the whole context collection and assigns it to the variable in the 1st argument.
- format:
any + collect($var exp) any*
- type:
- Collection-wise
- examples:
(1,2,3)/v:collect(_{$x}) / {. + $x/v:last()}; # = (4,5,6)
error/1
- description:
Interrupts the query/program evaluation and throws an exception (the Java's RuntimeException). $message contains the message/diognostics.
- format:
void error($message string) void
- type:
- Static
eval/0
- description:
Evaluates an (absolute) quoted expression from the context.
- format:
token eval() any*
- type:
- Element-wise
- examples:
(``1+2) / eval(); # = (3)
eval/1
- description:
In Libretto it is possible to forbid the evaluation of a block {...} by putting underscore "_" before it: _{...}. Such a suspended expression becomes an ordinary data value. For evaluation of the suspended expression, the function eval/1 is used. To evaluate exp in the context of Ctx, we write Ctx / eval(exp).
eval/1 is also used for evaluation parametrized strings: it evaluates values in curly brackets while leaving other parts of the parametrized string untouched:
(1,2,3)/v:eval("1 + {.} = {1 + .}") # = ("1 + 1 = 2", "1 + 2 = 3", "1 + 3 = 4")
'!' is used as a syntactic sugar for v:eval/1:
_{1+2}! # = 3
(1,2,3)/"1 + {.} = {1 + .}"! # = ("1 + 1 = 2", "1 + 2 = 3", "1 + 3 = 4")
- format:
any eval($tok {token, string}) any*
- type:
- Element-wise
- examples:
$term := ``. + 1; (1, 2)/eval($term); # = (2, 3)
eval("1+2"); #2 = (3)
eval/2
- description:
eval/2 does the same job as eval/1, but it can evaluate anonymuous functions with arguments and provides the application of escapers in case of parametrized strings. For instance, if we assign $f a anonymuous function with one argument:
$f := _($x) {. * $x};
then we can apply this function using eval/2:
(1,2,3) / v:eval($f, (5)); # = (5, 10, 15)
The second argument of eval/2 contains the sequence of actual parameters of the anonymuous functions ((5) in our case).
'!' can be used as a syntactic sugar here:
(1,2,3) / $f!(5); # = (5, 10, 15)
If eval/2 evaluates parametrized strings, then the 2nd argument contains an escaper for transforming the values of the expressions in curly brackets:
«<a>{«<b/>»}</a>»!; # = "<a><b/></a>"
«<a>{«<b/>»}</a>»!x:esc; # = "«<a>&lt;b/&gt;</a>»"
Here the inner string «<b/>» is modified by the function x:esc/1. Note that using « and » allows us to introduce nested strings. «a{«b»}a» without ! is an ordinary string, but with the indication of whether a quote is opening or closing (like with parentheses). The ascii equivalents of « and » are ^" and "^ respectively.
Any function with one argument can serve as the escaper:
def double($x) {$x + $x};
«A{«b»}a»!double; # = "Abba"
«a{1+2}a»!double; # = "a6a"
- format:
any eval($tok expr|string, $parm expr|string) any*
- type:
- Element-wise
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:
{token, string} execute() map:Map
- type:
- Element-wise
- examples:
"def f($x) {$x + 1}; f(5)+6;" / v:execute() / "query = {@query} answer = {@answer}"!; #2 = (query = ``function f($x) $x + 1; answer = "", query = ``f(5) + 6; answer = 12)
exit/1
- description:
Halts the computation and quits the interpreter with code $code. Note that exit/1 halts the whole JVM, so it must be used with care.
- format:
void exit($code int)
- type:
- Static
indexDelete/1
- description:
removes the index determined by the argument from the table of indexes.
- format:
indexDelete($indexname string)
- type:
- Static
indexKeys/1
- description:
returns the keys of the index named index-id and generated by set-index/2.
- format:
indexKeys($indexname string) *
- type:
- Static
- examples:
fn:getIndexKeys("lines") / fn:Count(); # = (37)
indexRemoveKey/1
- description:
removes the key from the index $indexname.
- format:
string(key) indexRemoveKey($indexname string)
- type:
- Element-wise
- examples:
("make", "better") / indexRemoveKey("line-index");
indexValues/1
- description:
Gets a value of the key in the 'reverse' mapping. E.g. if we want to have fast access from people to their grandparent, we can create the hash table:
index("gps", Person, ``., ``child/child);
then to get John's grandparent we write
&John / indexValues("gps");
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 index.
- format:
any(key)indexValues($index-name string) any(value)+
- type:
- Element-wise
index/1
- description:
Creates a new index with name $index-name.
- format:
index($index-name string)
- type:
- Static
index/3
- description:
Adds a new key/value pair to the index. If $keys and/or $values contain more than one value, then each key is linked to each value.
- format:
index($index-name string, $keys any, $values any)
- type:
- Static
index/4
- description:
Creates an index (vocabulary) index-name aimed at fast access to a value by its key. E.g. if we want to have fast access from people to their grandparent, we can create the index:
index("gps", Person, _{child/child}, _{.});
Now to get John's grandparent we write
&John / index-values("gps");
The arguments:
- 1st is the name of the index
- 2nd is the basic set for indexing
- 3rd (key) is indexing value corresponding to the basic element
- 4th (value) is indexed value corresponding to the basic element
In the example above each person &p is indexed by the grandchild
&p/(child/child)
- format:
set-index($index-name string, $domain any*, $key any, $value any)
- type:
- Static
label/3
- description:
label/3 sets the return point for deep return. Works together with rollback/1. label/3 is element-wise and tries each element of the context sequence. First, it tries to evaluate $maincode with the current context value, If the calculation is succesfully finished, then the value of label/3 is its result. If rollback/1 with the argument $pointname is envoked during this evaluation, the system returns to the nearest label point with the same point name and evaluates its $returncode,
- format:
void label($pointname string, $maincode exp, $returncode exp) any
- type:
- Element-wise
- examples:
def f() {if (. = "a") v:rollback("aaa") else .}; ("a", 1)/v:label("aaa", `{f()}, "aaaaa"); # = (1, "aaaaa")
load/1
- description:
Loads (evaluates) a Libretto script from the file or URL $libretto-filename.
- format:
load( $librettofilename string)
- type:
- Static
objects/1
- description:
Applies the o-property $prop to the context object.
- format:
object objects($prop oproperty) object*
- type:
- Element-wise
rollback/1
- description:
Performs the deep return to the nearest point set by function label/3 with the same $pointname.
- format:
void rollback($pointname string) void
- type:
- Static
sleep/1
- description:
Causes the current computation to sleep for the specified number of milliseconds $millis. Returns the current context value.
- format:
any sleep($millis long) any
- type:
- Element-wise
stop/0
- description:
Stops in a normal way the execution of a Libretto script.
- format:
void stop() void
- type:
- Static
void/1
- description:
Returns its argument.
- format:
void void($val any) any
- type:
- Static
x:a/0
- description:
Returns the sequence of the attributes of the context element.
- format:
x:Element x:a() x:Attribute*
- type:
- Element-wise
x:a/1
- description:
Returns the value of the attribute $key of the context element.
- format:
x:Element x:a($key string) string
- type:
- Element-wise
x:add/1
- description:
Adds an entity (element, attribute, text) to the context XML node (a node of either x:Element or x:Document). If the argument is not an XML node, it is converted to a string, escaped, and then added as a text node. If the argument is a sequence of elements, then each element is converted to a string, and then these strings are concatenated.
- format:
x:Element|x:Document x:add($entity {x:Element, x:Text, x:Attribute}) x:Element
- type:
- Static
x:attr/2
- description:
Creates a new xml attribute object in the XML heap ontology.
- format:
void x:attr($name string, $value string, $ontology-id {string(prefix), string(uri), ontology}) x:Attribute
- type:
- Static
x:doc/0
- description:
Creates a new XML document node in the XML heap ontology,
- format:
void x:doc() x:Document
- type:
- Static
x:e/0
- description:
Returns the sequence of the direct subelements of the context element in the standard order.
- format:
x:Element x:e() x:Element*
- type:
- Element-wise
x:e/1
- description:
Returns the sequence of all direct subelements of the context element with name $name in the standard order.
- format:
x:Element x:e($name string) x:Element*
- type:
- Element-wise
x:ee/0
- description:
Returns the sequence of all subelements of the context element (at any depth) in the standard order.
- format:
x:Element x:ee() x:Element*
- type:
- Element-wise
x:ee/1
- description:
Returns the sequence of all subelements of the context element with the name $name (at any depth) in the standard order.
- format:
x:Element x:ee($name string) x:Element*
- type:
- Element-wise
x:elem/1
- description:
Creates a new XML element node named $name in the XML heap ontology.
- format:
void x:elem($name string) x:Element
- type:
- Static
x:entities/0
- description:
Returns the names of all HTML5 named entities (references). See http://www.w3.org/TR/html5/named-character-references.html for details.
- format:
void x:entity() string+
- type:
- Static
x:entity/1
- description:
Returns the unicode of the HTML5 named or numeric character reference (the 1st argument). See http://www.w3.org/TR/html5/named-character-references.html for the HTML5 named character references.
- format:
void x:entity($reference string) int
- type:
- Static
- examples:
x:entity("lt") / v:codes-string(); # = "<"
x:entity("#x25") / v:codes-string(); # = "%"
x:esc/1
- description:
XML-escaping the string in the 1st argument. x:esc/1 can be used with the string evaluator '!'.
- format:
void x:esc($text string) string
- type:
- Static
- examples:
x:esc("<a>"); # = "&lt;a&gt;"
«<a>{"<a>"}</a>»!x:esc; # = "<a>&lt;a&gt;</a>"
x:getHeap/0
- description:
Gets the ontology currently used as the heap for XML entity objects.
- format:
void x:getHeap() ontology
- type:
- Static
x:id/0
- description:
Returns the id of the element, if it exists. Otherwise, returns nothing.
- format:
x:Element x:id() v:string
- type:
- Element-wise
x:id/1
- description:
Collects in the context the element with ID = $id.
- format:
x:Element x:id($id string) x:Element
- type:
- Element-wise
x:setHeap/1
- description:
Creates / assignes an ontology to be used as the heap for xml entity objects.
- format:
void x:setHeap($uri string) ontology
- type:
- Static
x:text/1
- description:
Creates a new xml text object in the XML heap ontology.
- format:
void x:text($txt string) x:Text
- type:
- Static
x:tt/0
- description:
Returns the text of the context element and all its subelements (at any depth) in the standard order.
- format:
x:Element x:tt() string*
- type:
- Element-wise
x:xpath/1