Functions Overview


afn:e (spin:Function)

Returns the value of e, as xsd:double.

Return type


afn:localname (spin:Function)

Returns the local name of a URI resource. Based on splitting the IRI, not on any prefixes in the query or dataset. For example, the local name of http://test.com/my#Example is Example.

Arguments

sp:arg1 (rdfs:Resource): the URI resource to get the local name of

Return type


afn:max (spin:Function)

Gets the max value of two numeric arguments.

Arguments

sp:arg1 (rdfs:Literal): the first value to compare
sp:arg2 (rdfs:Literal): the second value to compare

Return type


afn:min (spin:Function)

Gets the min value of two numeric arguments.

Arguments

sp:arg1 (rdfs:Literal): the first value to compare
sp:arg2 (rdfs:Literal): the second value to compare

Return type


afn:namespace (spin:Function)

Returns the namespace of a URI resource. Based on splitting the IRI, not on any prefixes in the query or dataset. For example, the namespace of http://test.com/my#Example is http://test.com/my#.

Arguments

sp:arg1 (rdfs:Resource): the URI resource to get the namespace of

Return type


afn:now (spin:Function)

Gets the current time as xsd:dateTime. Actually, the time the query started. Constant throughout a query execution.

Return type


afn:pi (spin:Function)

Returns the value of pi, as an xsd:double.

Return type


afn:sha1sum (spin:Function)

Computes the sha1sum of a given input value (?arg1).

Arguments

sp:arg1: the value to get the sha1sum of

Return type


afn:sprintf (spin:Function)

Make a string from the format string and the RDF terms.

Arguments

sp:arg1 (xsd:string): The format

Return type


afn:sqrt (spin:Function)

The square root of num.

Arguments

sp:arg1 (rdfs:Literal): The number to get the square root of.

Return type


afn:substr (spin:Function)

Extracts a substring, Java style using startIndex and endIndex.

Arguments

sp:arg1 (xsd:string): the text to get a sub string of
sp:arg2 (xsd:integer): the index of the first character (text starts with index 0)
sp:arg3 (xsd:integer): [Optional] the index of the last character to include in the result

Return type


fn:abs (spin:Function)

Returns the absolute value of the argument.

Arguments

sp:arg1 (rdfs:Literal): the number to get the absolute value of

Return type


fn:boolean (spin:Function)

Gets the effective boolean value of an input node, for example 1 becomes true.

Arguments

sp:arg1 (rdfs:Literal): The input value.

Return type


fn:ceiling (spin:Function)

Returns the smallest integer value less than the argument (as a double).

Arguments

sp:arg1 (rdfs:Literal): the number to get the ceiling of

Return type


fn:concat (spin:Function)

Returns the concatenation of two (or more) strings.

Arguments

sp:arg1 (xsd:string): the first string
sp:arg2 (xsd:string): the second string

Return type


fn:contains (spin:Function)

Checks if a string (?arg1) contains a given sub-string (?arg2).

Arguments

sp:arg1 (xsd:string): the (larger) string to search the substring in
sp:arg2 (xsd:string): the sub-string to search for

Return type


fn:ends-with (spin:Function)

Test whether string ends with substr.

Arguments

sp:arg1 (xsd:string): the (larger) text string to search in
sp:arg2 (xsd:string): the sub-string to search for

Return type


fn:floor (spin:Function)

Returns the greatest integer value less than the argument (as a double).

Arguments

sp:arg1 (rdfs:Literal): the number to get the floor of

Return type


fn:lower-case (spin:Function)

Returns a string which is the lower case equivalent of the argument.

Arguments

sp:arg1 (xsd:string): the string to convert to lower case

Return type


fn:matches (spin:Function)

Performs string pattern matching based on regular expressions.

Arguments

sp:arg1 (xsd:string): the string to search in
sp:arg2 (xsd:string): the pattern matching string
sp:arg3 (xsd:string): [Optional] the (optional) arguments for the regular expression matcher

Return type


fn:not (spin:Function)

Negates a boolean value.

Arguments

sp:arg1 (rdfs:Literal): The input node.

Return type


fn:round (spin:Function)

Returns the nearest integer value to the argument.

Arguments

sp:arg1 (rdfs:Literal): the number to round

Return type


fn:starts-with (spin:Function)

Test whether a string (?arg1) starts with a sub-string (?arg2).

Arguments

sp:arg1 (xsd:string): the (larger) string to search in
sp:arg2 (xsd:string): the sub-string to search for

Return type


fn:string-length (spin:Function)

Gets the length of a string (number of characters).

Arguments

sp:arg1 (xsd:string): the text string to get the length of

Return type


fn:substring (spin:Function)

Returns the substring of a string, given by a start index (integer) and, optionally, length. Absence of length means to end of string. Strings start from one, not zero as they do in Java and C#. 3rd argument is the length, like C# but unlike Java, where it is the endIndex.

Arguments

sp:arg1 (xsd:string): the text to get a sub-string of
sp:arg2 (xsd:integer): the index of the first character (1 is the first character)
sp:arg3 (xsd:integer): [Optional] the (optional) number of characters to include in the substring

Return type


fn:upper-case (spin:Function)

Returns a string which is the upper case equivalent of the argument.

Arguments

sp:arg1 (xsd:string): the text to convert to upper-case

Return type


smf:applicableFamily (spin:MagicProperty)

A magic property that can be used to walk through all applicable AssetFamilies for a WildCardAsset in the current TopBraid workspace. Example usage: ?wildcardAsset smf:applicableFamily ?family . An unbound variable is required on the right hand side. ?wildcardAsset can be bound to a wildcard asset which was returned from the smf:wildcardAsset magic property.

Arguments

sp:arg1 (xsd:string): The wildcard asset that was returned using smf:wildcardAsset.

Return type


smf:asInternationalPhoneNumber (spin:Function)

Takes the string of a phone number from a variety of formats, and an optional two-letter uppercase country code, and produces a "normalized" string using international conventions. Returns nothing if the phone number cannot be handled (use smf:isPhoneNumber beforehand).

Arguments

sp:arg1 (xsd:string): The string to check.
sp:arg2 (xsd:string): [Optional] The default country code, as an upper-case two letter abbreviation.

Return type


smf:baseURI (spin:Function)

Returns the base URI (resource) of a given file (?arg1), where the file is specified as a path string relative to the workspace root. This function might be used in conjunction with tops:files.

Arguments

sp:arg1 (xsd:string): The path string, e.g. "/MyProject/MyFolder/MyFile.rdf".

Return type


smf:canRead (spin:Function)

Checks if a given graph can be read (by the current user).

Arguments

sp:arg1 (rdfs:Resource): Graph base URI

Return type


smf:canWrite (spin:Function)

Checks if a given graph can be modified (by the current user).

Arguments

sp:arg1 (rdfs:Resource): Graph base URI

Return type


smf:checkCurrentUserRole (spin:Function)

Checks if current user belongs to a named role.

Arguments

arg:roleName (xsd:string): The name of the role to check.

Return type


smf:configParam (spin:Function)

Gets the value of a system configuration parameter from the dynamic config graph.

Arguments

arg:param (xsd:string): The local name of the parameter property, e.g. "smtpServer" for <http://server.topbraidlive.org/web/2009/config#smtpServer>.

Function body

SELECT ?result
WHERE {
    GRAPH <http://server.topbraidlive.org/dynamic/config> {
        BIND (IRI(CONCAT("http://server.topbraidlive.org/web/2009/config#", ?param)) AS ?predicate) .
        <http://server.topbraidlive.org/dynamic/config#configuration> ?predicate ?result .
    } .
}

smf:convertRDFToText (spin:Function)

Converts the current RDF graph to text. Optionally the serialization of the RDF graph as text can be given. By default, the serialization is Turtle.

Arguments

sp:arg1 (rdfs:Resource): [Optional] The optional serialization format of the output. By default, it is Turtle. This value should be an instance of "sml:RDFSerialization" from the sparqlmotionlib ontology, for example sml:RDFXML.
sp:arg2 (rdfs:Resource): [Optional] An optional pointer to the URI of a .context.json file - only used for JSON-LD.

Return type


smf:countResults (spin:Function)

Runs an nested SPARQL query and counts its results. Note that the nested query will reuse the variable bindings from its surrounding.

Arguments

sp:arg1 (xsd:string): the SPARQL select query string to execute

Return type


smf:createARFF (spin:Function)

Takes a SHACL shape and produces a Weka ARFF file as a string. The shape needs to declare sh:property constraints for each attribute. sh:maxCount 1 should be used for single-valued properties, otherwise the system will produce a new column/attribute for each value. The shape must declare a target, and all target nodes that conform to the shape will be turned into rows/instances in the ARFF file.

Arguments

arg:shape (rdfs:Resource): The shape defining the ARFF.

Return type


smf:currentBaseURI (spin:Function)

Gets the base URI of the current TopBraid session, as a URI resource. The current session is the currently open domain model of TBE or TBC. If used in SPARQLMotion scripts, this function may return the script's URI itself if executed within TBC, but the TBE session if executed from TBE.

Return type


smf:currentUserAttribute (spin:Function)

Gets a named attribute of the user that is currently logged into TopBraid. The attribute name must be present in the selected user management system (e.g. LDAP), and typical values include "company" and "mail".

Arguments

arg:attributeName (xsd:string): The name of the attribute to get (e.g. "company").

Return type


smf:currentUserName (spin:Function)

Gets the name of the user that is currently logged into TopBraid. Should be preceeded by smf:hasCurrentUser to avoid exceptions.

Return type


smf:dbpedia (spin:Function)

Attempts to get a DBPedia page for a string. Returns false if no matching DBPedia page could be found.

Arguments

sp:arg1 (xsd:string): the label to get a DBpedia resource for

Return type

Examples

smf:dbpedia("Dean Allemang")
Result:  http://dbpedia.org/resource/Dean_Allemang
smf:dbpedia("cycloyasi")
Result:  false
smf:dbpedia("Cyclone Yasi")
Result:  http://dbpedia.org/resource/Severe_Tropical_Cyclone_Yasi

smf:definedIn (spin:Function)

Returns the base URI of the ontology that the input resource is defined in. If the resource is defined in an unnamed graph (e.g., inference graph), then this function returns no value.

Arguments

sp:arg1 (rdfs:Resource): The input resource

Return type


smf:definedInFile (spin:Function)

Returns the workspace file path of the ontology that the input resource is defined in, if it exists.

Arguments

sp:arg1 (rdfs:Resource): The input resource

Return type


smf:deriveURI (spin:Function)

Constructs a new URI resource by concatenating a string constant {?arg2} to the URI of a given resource {?arg1}. Example: smf:deriveURI(owl:Thing, "-Child") = owl:Thing-Child

Arguments

sp:arg1 (rdfs:Resource): the URI resource that constitutes the left part of the new URI
sp:arg2 (xsd:string): the additional string that will be appended to the right of {?arg1}

Return type

Function body

SELECT ?uri
WHERE {
    BIND (smf:resource(fn:concat(xsd:string(?arg1), ?arg2)) AS ?uri) .
}

smf:duration (spin:Function)

Returns the duration between two dates in terms of one of the given "types". "type" is a string constant, which indicates the type of duration. It can be: String value - Explanation ms - milliseconds s - seconds m - minutes h - hours d - days mon - months y - years c - centuries

Arguments

sp:arg1 (xsd:string): The type of the duration: It can be one of: "ms", "s", "m", "h", "d", "mon", "y", "c".
sp:arg2: The begin date
sp:arg3: The end date

Return type


smf:escapeXML (spin:Function)

Encodes a string so that it can be inserted into XML documents. Special characters will be converted.

Arguments

sp:arg1 (xsd:string): The string to escape.

Return type


smf:file (spin:Function)

Gets the absolute path to the workspace file holding a given base URI (?arg1).

Arguments

sp:arg1: The base URI - either as string or a URI resource.

Return type


smf:generateLabel (spin:Function)

Can be used to derive a "human-readable" label from a resource URI or local name. For example, with the input ex:firstName this will return "first name". The result can then be used in the rest of the SPARQL query, e.g. to create an rdfs:label.

Arguments

sp:arg1: A URI resource or string literal that is used to generate a label. For URI resources, the local name will be used, the full string otherwise.
sp:arg2 (xsd:string): [Optional] An (optional) string template, that may include any of the following special commands: - {date} inserts the current date - {name} inserts the generated label - {name:lower-case} inserts the label as lower case - {name:upper-case} inserts the label as upper case - {name:title-case} insert the label as title case Any other characters will be inserted as they appear.

Return type


smf:geoCode (spin:Function)

Attempts to convert a textual address (?arg1) into a comma-separated pair of lat/long values. The implementation currently uses the Google API (http://code.google.com/apis/maps/documentation/geocoding/) to do the actual work.

Arguments

sp:arg1 (xsd:string): The address as a raw string, e.g. "1600 Amphitheatre Parkway, Mountain View, CA".
sp:arg2 (xsd:string): [Optional] An (optional) country code such as "au" to aid the search.

Return type


smf:groupHasUser (spin:MagicProperty)

A magic property that can be used to walk through all available TBUsers for a permission group in the current TopBraid workspace. Example usage: ?group smf:groupHasUser ?user . An unbound variable is required on the right hand side. ?group can be bound to a permission group which was returned from the pg:group magic property.

Arguments

sp:arg1 (xsd:string): The group to get the users of.

smf:hasAsset (spin:MagicProperty)

A magic property that can be used to walk through all available Assets and each Asset's AssetFamily for a project in the current TopBraid workspace. Example usage: ?project smf:hasAsset (?asset ?family) . A pair of unbound variables is required on the right hand side. ?project can be bound to a project which was returned from the smf:project magic property.

Arguments

sp:arg1 (xsd:string): The project, e.g. retrieved using smf:project.

smf:hasBaseURI (spin:Function)

Checks if a given file (?arg1) is known to have a base URI in the current workspace, where the file is specified as a path string relative to the workspace root. This function might be used in conjunction with tops:files.

Arguments

sp:arg1 (xsd:string): The path string, e.g. "/MyProject/MyFolder/MyFile.rdf".

Return type


smf:hasCurrentUser (spin:Function)

Checks if there is a user that is currently logged into TopBraid.

Return type


smf:hasFile (spin:Function)

Checks if there is any workspace file holding a given base URI (?arg1).

Arguments

sp:arg1: The base URI - either as string or a URI resource.

Return type


smf:hasLabelsPlugin (spin:Function)

Checks whether there are any "labels plugins" for a given blank node. In the TopBraid platform, labels plugins provide special rendering of certain blank nodes. For example, OWL restrictions are rendered in Manchester Syntax.

Arguments

arg:node (rdfs:Resource): The (blank) node for which the test is performed.

Return type


smf:htmlString (spin:Function)

Converts an input string to an HTML string - that is, special characters are converted.

Arguments

sp:arg1 (xsd:string): the input string

Return type


smf:importGraphCheck (spin:MagicProperty)

A magic property that can be used to find missing or duplicate imports given a base URI if no base URI is supplied the function will traverse all projects finding any missing or duplicate imports. Example usage: ?projects smf:importGraphCheck ?results . or <http://baseUri/location> smf:importGraphCheck ?results . An unbound variable is required on the right hand side. ?projects can be assigned a base URI value if searching a specific graph.

Arguments

sp:arg1 (xsd:string): The graph to search for missing or duplicate imports.

Return type


smf:isBound (spin:Function)

Checks whether the input expression evaluates to a bound variable. This is similar to the built-in bound function of SPARQL, but bound expects a variable as argument and therefore can not be used to evaluate arbitrary nested functions.

Arguments

sp:arg1 (rdfs:Resource): the argument or variable to evaluate

Return type


smf:isCachedGraph (spin:Function)

Checks if a given graph is cached. TopBraid applies a cache over all database graphs.

Arguments

arg:graph (rdfs:Resource): The graph (URI resource) to check.

Return type


smf:isDomainName (spin:Function)

Checks whether a given string is a domain name as specified by RFC1034/RFC1123 and according to the IANA-recognized list of top-level domains (TLDs). Returns nothing if the provided argument is not a literal.

Arguments

arg:string (xsd:string): The string to validate.

Return type


smf:isEmailAddress (spin:Function)

Checks whether a given string is a valid Email address according to RFC 822 standards. Returns unbound if the given argument is not a literal.

Arguments

arg:string (xsd:string): The string to validate.

Return type


smf:isIndividualsGraph (spin:Function)

Checks whether a given graph (contractually) only contains individuals, i.e. neither classes nor properties. This function does not actually look into the data, but currently assumes its result based on the following policies: In TBC-FE and SE, this always returns false. On the other platforms, it returns true for any graph under EVN/EDG teamwork control that is not an Ontology project (or of a similar asset type that declares teamwork:isOntologyProjectType=true. Note: For working copies or graphs containing the user name, this function will not work and needs to be called against the master graph instead.

Arguments

arg:graphURI (rdfs:Resource): The URI of the graph to test.

Return type


smf:isLDAPConfigured (spin:Function)

Returns true if LDAP has been configured in the TBL server administration.

Return type


smf:isPhoneNumber (spin:Function)

Checks whether a given string is a valid phone number, possibly in the context of a given default country code.

Arguments

sp:arg1 (xsd:string): The string to check.
sp:arg2 (xsd:string): [Optional] The default country code, as an upper-case two letter abbreviation.

Return type


smf:isTBL (spin:Function)

Checks whether the current working environment is TopBraid Live (stand-alone). False if we are in TopBraid Composer (including the personal server of Maestro Edition).

Return type


smf:isURL (spin:Function)

Checks whether a given string is a well-formed URL by checking the scheme, authority, path, query, and fragment in turn.

Arguments

arg:string (xsd:string): The string to check.

Return type


smf:isUserAccount (spin:Function)

Checks whether a given node represents a TopBraid user account (as produced by smf:userWithName).

Arguments

arg:node: The node to check.

Return type

Function body

ASK WHERE {
    BIND (smf:userName(?node) AS ?userName) .
    FILTER bound(?userName) .
}

smf:lastModified (spin:Function)

Gets the time stamp of last modification of the file associated with a given graph from the workspace.

Arguments

arg:graph: The URI of the graph to get the last modification of. May be a string or a URI resource.

Return type


smf:levenshteinDistance (spin:Function)

Computes the Levenshtein Distance between two strings.

Arguments

sp:arg1 (xsd:string): The first string.
sp:arg2 (xsd:string): The second string.

Return type


smf:localRange (spin:Function)

Gets the local range of a property at a class. The function first checks for locally defined owl:allValuesFrom restrictions on the class or its superclasses. If none is found, it will try to use the global rdfs:range of the property. If this does not exist either, it will return rdfs:Resource.

Arguments

sp:arg1 (rdfs:Class): the class to get the local range at
sp:arg2 (rdf:Property): the property to get the range of

Return type


smf:localSubjects (spin:MagicProperty)

If there is an unbound variable on the right hand side then this magic property assigns it to all subjects with a URI from the base graph of the current query graph (i.e. excluding those defined in imported sub-graphs). If there is a specific URI on the right hand side, the magic property checks whether that URI is a subject in the base graph.


smf:luceneFacetQuery (spin:MagicProperty)

A magic property that can be used to query the available facets for 'Search the EDG' system index. *This function is only available in TBC-ME and web products.*

Arguments

sp:arg1 (rdf:Property): The target property value.
sp:arg2 (xsd:integer): [Optional] The limit. If none provided the limit will default to 10.
sp:arg3 (xsd:string): [Optional] The query string expression.
sp:arg4 (rdfs:Resource): [Optional] The list of applied facet filters.

smf:luceneQuery (spin:MagicProperty)

A magic property that can be used to query the 'Search the EDG' system index. *This function is only available in TBC-ME and web products.*

Arguments

sp:arg1 (xsd:string): The query string expression.
sp:arg2 (rdfs:Resource): [Optional] A list of facet filters.
sp:arg3 (xsd:integer): [Optional] The offset. If none provided the offset will default to 0.
sp:arg4 (xsd:integer): [Optional] The limit. If none provided the limit default to 100.

smf:managedAssetsAndFamilies (spin:MagicProperty)

A magic property that can be used to walk through all available Assets and AssetFamilies for an asset permission group in the current TopBraid workspace. Example usage: ?group smf:managedAssetsAndFamilies (?asset ?family) . A pair of unbound variables is required on the right hand side.

Arguments

sp:arg1 (xsd:string): The name of a group to get the available assets and asset families for.

smf:managedRole (spin:MagicProperty)

A magic property that can be used to walk through all available roles for an asset permission group in the current TopBraid workspace. Example usage: ?group smf:managedRole ?role . An unbound variable is required on the right hand side. ?group can be bound to a group which was returned from the smf:permissionGroup magic property.

Arguments

sp:arg1 (xsd:string): The name of a group to get the roles of.

smf:maxCardinality (spin:Function)

Gets the maximum cardinality of a property at a class. The function checks for locally defined owl:maxCardinality restrictions on the class or its superclasses. If none is found, it will check if the property is functional and, if so, return 1. Otherwise it will return -1.

Arguments

sp:arg1 (rdfs:Class): the class to get the cardinality at
sp:arg2 (rdf:Property): the property to get the cardinality of

Return type


smf:memberOf (spin:MagicProperty)

A magic property that can be used to walk through all available Asset Permission Groups for a role in the current TopBraid workspace. Example usage: ?role smf:memberOf ?group . An unbound variable is required on the right hand side. ?role can be bound to a role which was returned from the smf:role magic property.

Arguments

sp:arg1 (xsd:string): The role to get the groups of.

smf:minCardinality (spin:Function)

Gets the minimum cardinality of a property at a class. The function checks for locally defined owl:minCardinality restrictions on the class or its superclasses. If none is found, it will return 0.

Arguments

sp:arg1 (rdfs:Class): the class to get the minimum cardinality at
sp:arg2 (rdf:Property): the property to get the cardinality of

Return type


smf:notManagedBy (spin:MagicProperty)

A magic property that can be used to walk through all available groups not currently associated with a specified role in the current TopBraid workspace. Example usage: ?role smf:notManagedBy ?group . An unbound variable is required on the right hand side. ?role can be bound to a role which was returned from the smf:role magic property.

Arguments

sp:arg1 (xsd:string): The role to get the unassociated groups of.

Return type


smf:parseManchesterSyntax (spin:Function)

Attempts to parse a string in OWL Manchester Syntax and returns an error string if something went wrong. Returns nothing (unbound) if the string could be parsed against the current query graph.

Arguments

sp:arg1 (xsd:string): The string to parse.

Return type


smf:permissionGroup (spin:MagicProperty)

A magic property that can be used to walk through all available Asset Permission Groups for the current TopBraid workspace. Example usage: () smf:permissionGroup ?group . An unbound variable is required on the right hand side.

Return type


smf:permissionsForAsset (spin:MagicProperty)

A magic property that can be used to walk through all available Permissions for an Asset in a group in the current TopBraid workspace. Example usage: (?group ?assetId ?family) smf:permissionsForAsset ?permission or (?group ?assetId) smf:permissionsForAsset ?permission An unbound variable is required on the right hand side. If ?family is not specified, then the GRAPH asset family will be assumed.

Arguments

sp:arg1 (xsd:string): The group to get the permissions for.
sp:arg2 (xsd:string): The asset to get the permissions of.
sp:arg3 (xsd:string): The asset family of the asset to get the permissions of.

smf:prefix (spin:Function)

Gets the prefix of a given resource (?arg1). Returns nothing if the argument is a URI that cannot be abbreviated with a prefix.

Arguments

sp:arg1 (rdfs:Resource): The resource to get the prefix of.

Return type

Function body

SELECT ?prefix
WHERE {
    BIND (smf:qname(?arg1) AS ?qname) .
    FILTER (!fn:starts-with(?qname, "<")) .
    BIND (smf:indexOf(?qname, ":") AS ?sep) .
    BIND (afn:substr(?qname, 0, ?sep) AS ?prefix) .
}

smf:project (spin:MagicProperty)

A magic property that can be used to walk through all known projects for the current TopBraid workspace. Example usage: () smf:project ?project . An unbound variable is required on the right hand side.

Return type


smf:qname (spin:Function)

Gets the qname of a resource, using the defined namespace abbreviations. In contrast to the official specs, this function will drop the : character if it's the first character in the string. If the resource does not have a suitable prefix abbreviation, the function will return the URI wrapped by <...>.

Arguments

sp:arg1 (rdfs:Resource): the URI resource to get the qname of

Return type


smf:resetCachedGraph (spin:Function)

Resets a given cached graph. This can be used to force a refresh of a TopBraid graph if the underlying database has been changed outside of TopBraid.

Arguments

arg:graph (rdfs:Resource): The graph (URI resource) to reset.

Return type


smf:role (spin:MagicProperty)

A magic property that can be used to walk through all available Roles for the current TopBraid workspace. Example usage: () smf:role ?role . An unbound variable is required on the right hand side.

Return type


smf:roleHasUser (spin:MagicProperty)

A magic property that can be used to walk through all available TBUsers for a role in the current TopBraid workspace. Example usage: ?role smf:roleHasUser ?user . An unbound variable is required on the right hand side. ?role can be bound to a role which was returned from the pg:role magic property.

Arguments

sp:arg1 (xsd:string): The role to get the users of.

smf:rootURISubject (spin:Function)

Takes a resource (usually a blank node) as argument and finds a URI resource that is the root of a blank node tree that contains the blank node. For example, if there is a blank node inside of a SPIN RDF structure that is linked to a class via spin:rule, then this function will return the class that points to the root of the SPIN RDF structure. Another example is OWL expressions such as owl:Restrictions.

Arguments

sp:arg1 (rdfs:Resource): The resource to find the reference to.

Return type


smf:setLanguage (spin:Function)

Creates a new string literal with a given language from an existing value. For example, smf:setLanguage("House", "en") becomes "House"@en.

Arguments

sp:arg1 (xsd:string): the text to set the language of
arg:language (xsd:string): the language of the result literal; may be empty to delete any existing language

Return type


smf:splitTextFile (spin:MagicProperty)

Can be used to split a file into multiple sub-strings separated based on a delimiter from a start record to the end record. For example, ("/myProject/myfile.txt" "\\n" 1 10) smf:splitTextFile ?result will open the file with the given absolute path, split its content for every new line, and return the first 10 entries starting with first one. An unbound variable must be placed on the right hand side of this magic property.

Arguments

sp:arg1 (xsd:string): The absolute path to the text file in the workspace (e.g., /myProject/myFolder/test.txt).
sp:arg2 (xsd:string): The delimiter string, for example "," for comma-separated lists.
sp:arg3 (xsd:integer): [Optional] The index of the first record to return, starting with 1.
sp:arg4 (xsd:integer): [Optional] The maximum number of records to return. May be left blank to get all entries.

Return type


smf:subGraph (spin:MagicProperty)

Can be used to query all named subgraphs of a given (SDB) graph. For example, http://example.org/graph/mysub is a subgraph of http://example.org/graph. The magic property only works if the base graph is given.

Arguments

sp:arg1 (rdfs:Resource): The base graph to get the subgraphs of.

Return type


smf:subString (spin:Function)

Extracts a substring from an input string. This is similar to afn:substr but more robust against null values.

Arguments

sp:arg1 (xsd:string): the input string
arg:fromIndex (xsd:integer): the start index (0 is the first character); if not bound, then the function will return null
arg:toIndex (xsd:integer): the end index; if not bound, use the length of text - 1

Return type


smf:trace (spin:Function)

Same as smf:buildString, but with the side effect of printing the string into TopBraid's Error Log. This can be used as a debugging aid. The result of the function is the evaluated template. You can control the log level by prefixing the template string with either of the following: - "INFO:" will record an info item in the log (default) - "WARN:" will record a warning in the log - "ERROR:" will actually throw and report an exeception For example: smf:trace("WARN: The value of {?1} is invalid", -10) will log a warning "smf:trace: The value of -10 is invalid".

Arguments

sp:arg1 (xsd:string): the template string to print

Return type


smf:tripleDefinedIn (spin:Function)

Returns the IRI of the subgraph that a given triple (subject, predicate, object) has been defined in. This is supported for graphs that are known to TopBraid's graph registry only, including union graphs such as those created with ui:graphWithImports.

Arguments

sp:arg1 (rdfs:Resource): The subject of the triple.
sp:arg2 (rdf:Property): The predicate of the triple.
sp:arg3: The object of the triple.

Return type


smf:turtleString (spin:Function)

Returns a Turtle (source code) representation of a given RDF node, using the prefixes from the current query graph. For blank nodes this includes depending triples, for URIs and literals just the single value rendering.

Arguments

arg:resource: The RDF node to render into Turtle.

Return type


smf:unmanagedRole (spin:MagicProperty)

A magic property that can be used to walk through all available roles not currently associated with a specified asset permission group in the current TopBraid workspace. Example usage: ?group smf:unmanagedRole ?role . An unbound variable is required on the right hand side. ?group can be bound to a group which was returned from the smf:permissionGroup magic property.

Arguments

sp:arg1 (xsd:string): The group to get the unavailable roles.

smf:user (spin:MagicProperty)

A magic property that can be used to walk through all available users in the current TopBraid workspace. Example usage: () smf:user ?user . An unbound variable is required on the right hand side.

Return type


smf:userDisplayName (spin:Function)

Gets the display name of a user with a given URI (of the form urn:x-tb-users:XY). Note that the result of this can not necessarily be used as input to smf:userwithName, because the display name may be different from the internal user name.

Arguments

arg:user (rdfs:Resource): The URI node of the user.

Return type


smf:userEmail (spin:Function)

Gets the email address associated with a user with a given URI (of the form urn:x-tb-users:XY). This could be retrieved from the LDAP directory, or from any property with local name "email" in the users.ttl file, or from the property edg:email in the active query graph.

Arguments

arg:user (rdfs:Resource): The URI node of the user.

Return type


smf:userName (spin:Function)

Converts a user URI resource into a user name. Returns nothing if the given node is not a URI that follows the URI naming pattern used by TopBraid. The inverse function is smf:userWithName.

Arguments

sp:arg1 (rdfs:Resource): The user resource to convert to a name.

Return type


smf:userRole (spin:MagicProperty)

This magic property requires a user resource on the left hand and an unbound variable on the right. This variable will contain the URIs of the security roles (e.g. LDAP) that the given user is known to have.

Arguments

sp:arg1 (rdfs:Resource): The user resource.

Return type


smf:userWithName (spin:Function)

Converts a user name into a URI resource, following the default settings in TopBraid. Often used in conjunction with smf:currentUserName(). The inverse function is smf:userName.

Arguments

sp:arg1 (xsd:string): The user name to convert to a resource.

Return type


smf:wekaClassifiers (spin:MagicProperty)

Gets the keys of all Weka classifiers that are currently on the configured Maui server. Usually they will have been created using sml:CreateWekaClassifier, but they may still be around from a previous run of a TopBraid product. The magic property takes nothing on the left hand side and needs an unbound variable on the right hand side, e.g. () smf:wekaClassifiers ?key .

Return type


smf:wekaClassify (spin:Function)

Classifies a given resource via Weka. The classifier must be executing on the configured Maui server, typically created in a previous step using sml:CreateWekaClassifier. This function here uses the trained Weka classifier to produce a suggestion for the property/path that has been specified when the classifier was created.

Arguments

arg:key (xsd:string): The key of the Weka classifier. Must be the same as the sml:key used in sml:CreateWekaClassifier.
arg:resource (rdfs:Resource): The resource to classify.
arg:shape (rdfs:Resource): The shape defining which properties/paths have to be sent to the Weka engine.

smf:wildcardAsset (spin:MagicProperty)

A magic property that can be used to walk through all available WildCardAssets for the current TopBraid workspace. Example usage: () smf:wildcardAsset (?wildcardAsset ?family) A pair of unbound variables is required on the right hand side.


smf:workspacePath (spin:Function)

Gets the absolute path of the workspace in the local hard disk.

Return type


spif:buildString (spin:Function)

Constructs a new string by inserting the existing variable bindings into a template. The template can mention variable names in curly braces, such as "Hello {?index}" would create "Hello 42" is ?index has the value 42. As an alternative to variable names, the function can take additional arguments after the template, the variables of which can be accessed using {?1}, {?2} etc. For example: smf:buildString("Hello-{?1}-{?2}", ?day, ?month) would insert day and month at places {?1} and {?2}.

Arguments

sp:arg1 (xsd:string): the template string

Return type


spif:buildStringFromRDFList (spin:Function)

Builds a string from the members of a given rdf:List (?arg1). The function iterates over all members of the list (which must be well-formed according to the RDF syntax rules). For each member, a string template (?arg2) is applied where the expression {?member} will be substituted with the current member. Optionally, a separator (?arg3) can be inserted between the list members in the result string, e.g. to insert a comma.

Arguments

sp:arg1 (rdf:List): the head of the rdf:List to convert to string
sp:arg2 (xsd:string): the template string
sp:arg3 (xsd:string): [Optional] the separator to insert between each string

Return type


spif:buildURI (spin:Function)

Constructs a new URI resource by inserting the existing variable bindings into a template. The template can mention variable names in curly braces, such as "my:Instance-{?index}" would create "my:Instance-42" is ?index has the value 42. As an alternative to variable names, the function can take additional arguments after the template, the variables of which can be accessed using {?1}, {?2} etc. For example: smf:buildURI("my:Instance-{?1}-{?2}", ?day, ?month) would insert day and month at places {?1} and {?2}.

Arguments

sp:arg1 (xsd:string): The URI template such as "<http://my.com/Instance-{?index}>". If the template contains a full URI, then it must be wrapped by <...>, otherwise the system will treat it as a qname.

Return type


spif:buildUniqueURI (spin:Function)

A variation of smf:buildURI that also makes sure that the created URI is unique in the current graph (that is, no triple contains the URI as either subject, predicate or object). This function is particularly useful for ontology mapping from a legacy data source into an RDF model.

Arguments

sp:arg1 (xsd:string): The URI template such as "<http://my.com/Instance-{?index}>". If the template contains a full URI, then it must be wrapped by <...>, otherwise the system will treat it as a qname.

Return type


spif:camelCase (spin:Function)

Converts an input string into camel case. For example, "semantic web" becomes "SemanticWeb". An optional matching expression can be given to only convert the matched characters.

Arguments

sp:arg1 (xsd:string): the input string
sp:arg2 (xsd:string): [Optional] The match expression

Return type


spif:canInvoke (spin:Function)

Checks whether a given SPIN function (?arg1) can be invoked with a given list of argument (?arg2, ?arg3, ...) without violating any of its declared SPIN constraints. In addition to the usual argument declarations, the SPIN function may declare ASK and CONSTRUCT queries to check additional pre-conditions.

Arguments

sp:arg1 (spin:Function): The function to check.
sp:arg2: [Optional] The first argument of the function call.
sp:arg3: [Optional] The second argument of the function call.
sp:arg4: [Optional] The third argument of the function call.
sp:arg5: [Optional] The forth argument of the function call.

Return type


spif:cast (spin:Function)

Creates a new literal from an existing literal, but with a different datatype. This can, for example, be used to convert between floating point values and int values.

Arguments

sp:arg1 (rdfs:Literal): the "old" literal that shall be converted
arg:datatype (rdfs:Datatype): [Optional] The target datatype, e.g. xsd:integer. Leave blank for untyped literals.

Return type


spif:checkRegexSyntax (spin:Function)

Takes a string and checks whether it would be a valid regular expression. Returns unbound if OK, or a string with an error message otherwise.

Arguments

arg:regex (xsd:string): The potential regular expression to check.

Return type


spif:convertSPINRDFToString (spin:Function)

Converts a SPARQL query encoded in SPIN RDF format to a SPARQL string in textual form. The SPIN query must be well-formed in the context graph at execution time, and the provided argument must be the root of the expression (e.g., an instance of sp:Select). This function is available as part of the TopBraid SPIN Libraries.

Arguments

sp:arg1 (sp:Query): the root of the SPIN RDF query
sp:arg2 (xsd:boolean): [Optional] true to embed HTML markup into the output

Return type


spif:countMatches (spin:Function)

Counts all occurrences of a triple pattern based on subject (?arg1), predicate (?arg2) and object (?arg3) input. Any of those can be unbound variables. This function is available as part of the TopBraid SPIN Libraries.

Arguments

sp:arg1 (rdfs:Resource): the subject in the match triple, or an unbound variable for a wildcard
sp:arg2 (rdf:Property): the predicate in the match triple, or an unbound variable for a wildcard
sp:arg3: the object in the match triple, or an unbound variable for a wildcard

Return type


spif:countTransitiveObjects (spin:Function)

Given a predicate and an object, this function computes the number of matches using SELECT (COUNT(DISTINCT ?object) AS ?result) WHERE { ?subject ?predicate* ?object . } The main purpose of this function is to optimize performance - this direction of * traversal is currently very slow in Jena. The function can be used to compute the number of superclasses of a given class.

Arguments

sp:arg1 (rdf:Property): The predicate to walk.
sp:arg2 (rdfs:Resource): The object to start traversal at.

Return type


spif:countTransitiveSubjects (spin:Function)

Given a predicate and an object, this function computes the number of matches using SELECT (COUNT(DISTINCT ?subject) AS ?result) WHERE { ?subject ?predicate* ?object . } The main purpose of this function is to optimize performance - this direction of * traversal is currently very slow in Jena. The function can be used to compute the number of subclasses of a given class.

Arguments

sp:arg1 (rdf:Property): The predicate to walk.
sp:arg2 (rdfs:Resource): The object to start traversal at.

Return type


spif:currentTimeMillis (spin:Function)

Returns the current time in milliseconds. See System.currentTimeMillis() in Java.

Return type


spif:dateFormat (spin:Function)

Takes a date/time literal and a pattern and renders the date according to the pattern. This is a reverse of spif:parseDate and uses the same format.

Arguments

arg:date: An xsd:date, xsd:dateTime or xsd:time literal containing the date and time to render.
arg:pattern (xsd:string): The output pattern.

Return type

Examples

spif:dateFormat("2008-02-13"^^xsd:date, "MMMMMMMMM dd, yyyy")
Result:  February 13, 2008
spif:dateFormat("01:02:03"^^xsd:time, "hh::mm")
Result:  01::02

spif:decimalFormat (spin:Function)

Takes a number as its first argument and applies a given formatting string to it, for example, to convert a floating point into a number that has exactly two decimal places after the dot. For example, spif:decimalFormat(12.3456, "#.##") returns "12.35". The resulting string can then by cast back to a number, e.g. using xsd:double(?str).

Arguments

arg:number (xsd:decimal): The number to format.
arg:pattern (xsd:string): The pattern, following the syntax defined for the Java DecimalFormat class (see: http://download.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html).

Return type

Examples

spif:decimalFormat(12.3456, "#.##")
Result:  12.35

spif:decodeURL (spin:Function)

Decodes a URL string - this is the inverse operation of spif:encodeURL.

Arguments

sp:arg1 (xsd:string): The URL to decode.
sp:arg2 (xsd:string): [Optional] The (optional) encoding. Defaults to UTF-8.

Return type


spif:encodeURL (spin:Function)

Encodes a URL string, for example so that it can be passed as an argument to REST services.

Arguments

sp:arg1 (xsd:string): The URL to encode.
sp:arg2 (xsd:string): [Optional] The (optional) encoding. Defaults to UTF-8.

Return type


spif:evalPath (spin:MagicProperty)

Takes a starting node (?arg1) and a SPARQL path expression (?arg2) and binds all matching results of the path evaluation. Also supports cases where the starting node is unbound, even both unbound.

Arguments

sp:arg1 (rdfs:Resource): The start node.
sp:arg2: The path expression, as a parsable string, or a IRI resource for a simple path consisting of a single property only.

spif:for (spin:MagicProperty)

Can be used to iterate over a range of (integer) numbers similar to a for loop in iterative programming languages. An unbound variable must be placed on the left side of this magic property. On the right side, a list of two numbers needs to be placed. For example, ?index spif:for (1 10) binds ?index to all xsd:integers >= 1 and <= 10. By default it will add +1 to each step. It is possible to walk different steps and direction by specifying a third argument on the right, e.g. ?index spif:for (10 1 -1) will walk from 10 to 1 backwards.


spif:foreach (spin:MagicProperty)

Can be used to "iterate" over a list of RDF nodes given as members of a list on the right. An unbound variable must be on the left side of the magic property. On the right side, a list of nodes with arbitrary length can be placed. For example, ?subject spif:foreach (owl:Thing owl:Nothing) will bind ?subject to owl:Thing and then owl:Nothing.


spif:generateLabel (spin:Function)

Constructs a human-readable label for a URI resource by taking everything after the last '/' or the last '#' as starting point.

Arguments

sp:arg1 (rdfs:Resource): The resource to generate a label for.

Return type

Function body

SELECT ?label
WHERE {
    BIND (spif:localName(?arg1) AS ?localName) .
    BIND (spif:unCamelCase(?localName) AS ?label) .
}

Examples

spif:generateLabel(<http://example.org/test#LocalName>)
Result:  Local name
spif:generateLabel(<http://example.org/test/123>)
Result:  123

spif:generateUUID (spin:Function)

Generates a new unique ID as a string literal. This is often useful for creating "random" URIs and other identifiers.

Return type


spif:graphExists (spin:Function)

Checks whether a given graph URI is known to the dataset. This also returns true for graphs that are empty.

Arguments

arg:graph (rdfs:Resource): The graph (IRI) to test.

Return type


spif:graphIsomorphicWith (spin:Function)

Checks whether the current query graph is isomorphic with a given named graph. This compares all triples in the graphs, matching equivalent blank node structures even if they have different internal identities.

Arguments

arg:graph (rdfs:Resource): The graph to compare the current query graph with.

Return type


spif:graphSize (spin:Function)

Counts the number of triples in the current query graph and returns that sum as an xsd:integer.

Return type


spif:hasAllObjects (spin:Function)

Checks whether a given subject/predicate combination has all values enumerated from a given rdf:List. In other words, for each member ?object of the rdf:List, the triple (?arg1, ?arg2, ?object) must be in the model to return true. If the list is empty, true will also be returned.

Arguments

sp:arg1 (rdfs:Resource): the match subject
sp:arg2 (rdf:Property): the match predicate
sp:arg3 (rdf:List): an rdf:List containing the match objects

Return type


spif:indexOf (spin:Function)

Gets the index of the first occurrence of a certain substring in a given search string. Returns an error if the substring is not found.

Arguments

sp:arg1 (xsd:string): the string to search in
sp:arg2 (xsd:string): the sub string to search for
sp:arg3 (xsd:integer): [Optional] The optional index to start with.

Return type


spif:invoke (spin:Function)

Calls another SPARQL function specified by a URI resource (?arg1), with any number of additional arguments to be passed into the function (?arg2, ?arg3, ...). The result of the function call will be returned as result of the invoke call. This can be used to dynamically call functions when their URI is not known statically. The function can also be a binary built-in SPARQL function using the SPIN function identifiers from the SPL ontology. For example, sp:gt will be executed as ?left > ?right.

Arguments

sp:arg1 (spin:Function): The URI resource defining the function to call.
sp:arg2: [Optional] The first argument of the function call.
sp:arg3: [Optional] The second argument of the function call.
sp:arg4: [Optional] The third argument of the function call.
sp:arg5: [Optional] The forth argument of the function call.

spif:isReadOnlyTriple (spin:Function)

Checks whether a given triple is read-only, that is, cannot be deleted. Triples that are in the system ontology are generally not deletable. TopBraid also enforces that on union graphs, all triples that are not from the base graph of the union are read-only. Other platforms may have different privilege rules for this function.

Arguments

sp:arg1 (rdfs:Resource): The subject of the triple to delete.
sp:arg2 (rdf:Property): The predicate of the triple to delete.
sp:arg3: The object of the triple to delete.

Return type


spif:isValidForDatatype (spin:Function)

Checks whether the lexical form of a given data literal would be a valid value for a given datatype.

Arguments

arg:data: The data node.
arg:datatype (rdfs:Datatype): The XSD datatype to test against.

Return type


spif:isValidLangTag (spin:Function)

Checks whether a given string is a valid language tag.

Arguments

sp:arg1 (xsd:string): The string to check.

Return type


spif:isValidURI (spin:Function)

Checks whether a given input string is a well-formed absolute URI. This can be used to validate user input before it is turned into a URI resource.

Arguments

sp:arg1 (xsd:string): The string to validate.

Return type


spif:labelTemplateSegment (spin:MagicProperty)

Takes a Template and splits its spin:labelTemplate into an iteration over string constants or properties. The properties align with the spl:predicates of the declared spl:Arguments of the template. Among others, this magic property can be used to render template calls into user interface components.

Arguments

sp:arg1 (spin:Template): The template to get the label segments of.

spif:lastIndexOf (spin:Function)

Gets the index of the last occurrence of a certain substring in a given search string. Returns an error if the substring is not found.

Arguments

sp:arg1 (xsd:string): the string to search in
sp:arg2 (xsd:string): the sub string to search for
sp:arg3 (xsd:integer): [Optional] The optional index to start with.

Return type


spif:localName (spin:Function)

Gets a "local name" from a URI resource. This takes everything after the last '/' or '#' character of the URI. This function is a more intuitive alternative to afn:localname, which strictly follows the W3C namespace splitting algorithm that often leads to surprising results.

Arguments

sp:arg1 (rdfs:Resource): The URI resource to get the local name of.

Return type

Function body

SELECT ?localName
WHERE {
    BIND (xsd:string(?arg1) AS ?uri) .
    BIND (spif:lastIndexOf(?uri, "/") AS ?slash) .
    BIND (spif:lastIndexOf(?uri, "#") AS ?hash) .
    BIND (IF(((!bound(?hash)) || (bound(?slash) && (?slash > ?hash))), ?slash, ?hash) AS ?sep) .
    BIND (fn:substring(?uri, (?sep + 2)) AS ?localName) .
}

Examples

spif:localName(<http://example.org/test#Aldi>)
Result:  Aldi
spif:localName(<http://example.org/test/.123>)
Result:  .123

spif:lowerCamelCase (spin:Function)

Converts an input string into lower camel case. For example, "semantic web" becomes "semanticWeb". An optional matching expression can be given to only convert the matched characters.

Arguments

sp:arg1 (xsd:string): the input string
sp:arg2 (xsd:string): [Optional] The match expression

Return type


spif:lowerCase (spin:Function)

Converts an input string into lower case. For example, "SEMANTIC Web" becomes "semantic web". An optional matching expression can be given to only convert the matched characters.

Arguments

sp:arg1 (xsd:string): the input string
sp:arg2 (xsd:string): [Optional] The match expression

Return type


spif:lowerTitleCase (spin:Function)

Converts an input string into lower title case. For example, "semantic web" becomes "semantic Web". An optional matching expression can be given to only convert the matched characters.

Arguments

sp:arg1 (xsd:string): the input string
sp:arg2 (xsd:string): [Optional] The match expression

Return type


spif:mod (spin:Function)

The mathematical modulo operator, aka % in Java.

Arguments

sp:arg1 (xsd:integer): The first operand.
sp:arg2 (xsd:integer): The second argument.

Return type

Examples

spif:mod(3, 2)
Result:  1

spif:name (spin:Function)

Gets a human-readable string representation from an RDF node. If it's a literal, the function will return the literal's lexical text. If it's a resource the system will use the rdfs:label (if exists) or otherwise use the qname. For an unbound input, the function will return no value.

Arguments

sp:arg1: the node (literal or resource) that shall be rendered into a string

Return type


spif:parseDate (spin:Function)

Converts a string in a semi-structured format into a xsd:date, xsd:dateTime or xsd:time literal. The input string must be in a given template format, e.g. "yyyy.MM.dd G 'at' HH:mm:ss z" for strings such as 2001.07.04 AD at 12:08:56 PDT.

Arguments

sp:arg1 (xsd:string): the input text
arg:pattern (xsd:string): The template of the input string. This must conform to the pattern language implemented by the Java SimpleDateFormat class (http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html).
arg:patternLanguage (xsd:string): [Optional] The code of the language (e.g. "de" for German) to use for parsing.

Return type

Examples

spif:parseDate("February 13, 2008", "MMMMMMMMM dd, yyyy")
Result:  2008-02-13
spif:parseDate("February 13 2008", "MMMMMMMMM dd yyyy")
Result:  2008-02-13
spif:parseDate("2/13/2008", "MM/dd/yyyy")
Result:  2008-02-13
spif:parseDate("13.02.2008", "dd.MM.yyyy")
Result:  2008-02-13
spif:parseDate("13 February, 2008", "dd MMMMMMMMM, yyyy")
Result:  2008-02-13
spif:parseDate("13 February 2008", "dd MMMMMMMMM yyyy")
Result:  2008-02-13
spif:parseDate("13/2/2008", "dd/MM/yyyy")
Result:  2008-02-13
spif:parseDate("1830", "hhmm")
Result:  18:30:00
spif:parseDate("20080213", "yyyyMMdd")
Result:  2008-02-13
spif:parseDate("200802131830", "yyyyMMddhhmm")
Result:  2008-02-13T18:30:00

spif:prefix (spin:MagicProperty)

Can be used to get namespaces and their prefixes. This magic property takes the namespace (string) or a variable on the left and a prefix or a variable on the right. If both are unbound variables, then it will iterate over all namespaces and their prefixes. Otherwise it will bind the namespace or prefix. If both are bound, the system checks whether the given prefix is for the given namespace.

Arguments

sp:arg1 (xsd:string): The namespace (string) or an unbound variable.

Return type


spif:random (spin:Function)

Creates a random xsd:double between 0 and 1.

Return type


spif:referencedVar (spin:MagicProperty)

For a given SPIN RDF expression or command (left hand side) this magic property delivers all used variables (right hand side). The algorithm basically walks into all depending blank nodes from the root and returns all unique values of sp:varName.


spif:regex (spin:Function)

An input string is converted into a result string by applying a match and replacement expressions. For example, the input string "semantic web" with the match expression "([A-z]+) ([A-z]+)" and the replacement expression "The $1 life" returns the string "The semantic life". An optional input string is returned, if no match occurs. If this string is empty and no match occurs, then the result string is unbound.

Arguments

sp:arg1 (xsd:string): the input string
sp:arg2 (xsd:string): The match expression
sp:arg3 (xsd:string): The replacement expression
sp:arg4 (xsd:string): [Optional] The optional string returned as result string if no match occurs. If this string is empty and no match occurs, then the result string is unbound.

Return type


spif:replaceAll (spin:Function)

Does a string replacement based on the Java function String.replaceAll().

Arguments

sp:arg1 (xsd:string): The string to operate on.
sp:arg2 (xsd:string): The regular expression to search for.
sp:arg3 (xsd:string): The replacement string.

Return type


spif:shortestObjectsPath (spin:Function)

Finds the shortest path from a given subject walking up a given predicate (for example, rdfs:subClassOf) and returns the path as a string of URIs separated with a space. This can be used to find the shortest path from a resource in a tree structure to the root resource.

Arguments

sp:arg1 (rdfs:Resource): The subject to start with.
sp:arg2 (rdf:Property): The predicate to walk, e.g. rdfs:subClassOf or skos:broader.
sp:arg3 (rdfs:Resource): [Optional] The optional target resource (root of the tree). If not specified, then the first node that has no further objects will be used.

Return type


spif:shortestSubjectsPath (spin:Function)

Finds the shortest path from a given object walking up a given predicate (for example, schema:child) and returns the path as a string of URIs separated with a space. This can be used to find the shortest path from a resource in a tree structure to the root resource.

Arguments

sp:arg1 (rdfs:Resource): The object to start with.
sp:arg2 (rdf:Property): The predicate to walk, e.g. schema:child.
sp:arg3 (rdfs:Resource): [Optional] The optional target resource (root of the tree). If not specified, then the first node that has no further subjects will be used.

Return type


spif:split (spin:MagicProperty)

Splits a given string and iterates over all sub-strings. An unbound variable must be placed on the left side of this magic property. A list with two members must be on the right. The first is the string to split, and the second is a regular expression. For example, ?str spif:split ("Hello World" " ") will bind ?str to "Hello" and "World".


spif:timeMillis (spin:Function)

Returns the time of a given xsd:dateTime value in milliseconds.

Arguments

sp:arg1 (xsd:dateTime): The xsd:dateTime to convert.

Return type


spif:timeMillisToDateTime (spin:Function)

Converts a given time milliseconds value (xsd:long or xsd:integer) into a corresponding xsd:dateTime literal.

Arguments

arg:millis (xsd:long): The milliseconds to convert.

spif:titleCase (spin:Function)

Converts an input string to title case. For example, "germany" becomes "Germany". An optional matching expression can be given to only convert the matched characters.

Arguments

sp:arg1 (xsd:string): The input string
sp:arg2 (xsd:string): [Optional] The match expression

Return type


spif:toJavaIdentifier (spin:Function)

Produces a valid Java identifier based on a given input string, dropping any characters that would not be valid Java identifiers. Produces the empty string if no character can be reused from the given string. Note that this function is even stricter than the normal Java identifier algorithm, as it only allows ASCII characters or digits.

Arguments

sp:arg1 (xsd:string): The input string.

Return type


spif:trim (spin:Function)

Creates a new string value by trimming an input string. Leading and trailing whitespaces are deleted.

Arguments

sp:arg1 (xsd:string): the text to trim

Return type


spif:unCamelCase (spin:Function)

Converts an input string into a reverse camel case.

Arguments

sp:arg1 (xsd:string): the input string

Return type

Examples

spif:unCamelCase("SemanticWeb")
Result:  Semantic web
spif:unCamelCase("semanTic_Web23")
Result:  seman tic Web23

spif:upperCase (spin:Function)

Converts an input string into upper case. For example, "semantic web" becomes "SEMANTIC WEB". An optional matching expression can be given to only convert the matched characters.

Arguments

sp:arg1 (xsd:string): The input string
sp:arg2 (xsd:string): [Optional] The match expression

Return type


spif:walkObjects (spin:Function)

Performs a depth-first tree traversal starting at a given node (?arg1) and then following the objects using a given predicate (?arg2). For each node it applies a given function (?arg3) that must take the current node as its first argument. All other arguments of the walkObjects function call will be passed into that function. The traversal stops on the first non-null result of the nested function calls. As use case of this function is to walk up superclasses, e.g. to find the "nearest" owl:Restriction of a certain kind.

Arguments

sp:arg1 (rdfs:Resource): The start node of the traversal.
sp:arg2 (rdf:Property): The property to walk up.
sp:arg3 (spin:Function): The SPIN/SPARQL function to execute for each node.

spin:ask (spin:Function)

Executes a given ASK query and returns its boolean result. The first argument must point to an sp:Ask or a SPIN template call that has an ASK query as its body. All subsequent argument can come in pairs, with the first one being a variable name and the second its binding. Example: BIND (spin:ask(?query, "this", owl:Thing) AS ?result) . will execute the sp:Ask behind ?query with the variable ?this pre-bound to owl:Thing.


spin:construct (spin:MagicProperty)

Evaluates a given sp:Construct or SPIN template call (first argument on the left hand side) and binds the resulting triples to the variables on the right hand side. Example: (?query "this" owl:Thing) spin:construct (?s ?p ?o) will execute the sp:Construct ?query using the binding of owl:Thing to ?this. The resulting triples will be bound to ?s, ?p and ?o. If any of ?s ?p ?o are bound, it will only return the matching triples.


spin:constructViolations (spin:MagicProperty)

Takes an instance (?arg1) and a class definition (?arg2) and returns all constraint violations for that instance as triples. This magic property basically runs its own constraint checker for defining meta-constraints, and can also be used to classify instances. Example: CONSTRUCT { ?s ?p ?o . } WHERE { (my:Person my:OldPerson) spin:constructViolations (?s ?p ?o) . }

Arguments

sp:arg1 (rdfs:Resource): The instance to check.
sp:arg2 (rdfs:Class): The class that this type is validated against.

spin:eval (spin:Function)

Evaluates a given SPIN expression or SELECT or ASK query, and returns its result. The first argument must be the expression in SPIN RDF syntax. All other arguments must come in pairs: first a property name, and then a value. These name/value pairs will be pre-bound variables for the execution of the expression.

Arguments

sp:arg1: The expression to evaluate. Should be a sp:Select, sp:Ask, a sp:Variable or an instance of a SPARQL function class, but may also be a simple RDF value.

spin:evalInGraph (spin:Function)

Evaluates a given SPIN expression or SELECT or ASK query, and returns its result. The first argument must be the expression in SPIN RDF syntax. This RDF representation of this expression is expected to be in the currently active query graph. The second argument is the URI of a graph that the actual query shall be evaluated against. All other arguments must come in pairs: first a property name, and then a value. These name/value pairs will be pre-bound variables for the execution of the expression.


spin:select (spin:MagicProperty)

Executes a given SELECT or ASK query (or a corresponding SPIN template call) and binds its result rows to the variables specified on the right hand side. May also pre-bind variables for the query execution, using name-value pairs on the left hand side. Example: (?query "this" owl:Thing) spin:select (?a ?b) will execute the sp:Select or sp:Ask that ?query points to and pre-bind ?this with the value of owl:Thing for the execution of the query. The first result variable of the query's result set will be bound to ?a, the second to ?b etc. If the nodes on the right are bound (or constants) then it will match with the values from the result set. Note that the first argument on the left hand side can be an instance of a SPIN template (but not the template itself). If you need to execute a template, retrieve its spin:body first.


spin:violatesConstraints (spin:Function)

Checks whether a given instance (?arg1) violates any of the constraints defined for a given class (?arg2).

Arguments

sp:arg1 (rdfs:Resource): The instance to check.
sp:arg2 (rdfs:Class): The class to get the constraints of.

Return type


spinmap:equals (spin:Function)

Returns the input value unchanged. This is a placeholder to indicate that a direct link between two properties shall be created. Technically, it creates the value(s) for the target property using the value(s) of the source property as provided by the argument (?arg1).

Arguments

sp:arg1: The value to copy.

Function body

SELECT ?arg1
WHERE {
}

spinmap:targetResource (spin:Function)

Gets the resource that is target of a mapping, based on a provided mapping context (?context) and a source resource (?arg1).

Arguments

sp:arg1 (rdfs:Resource): The source resource that will be passed into the function.
spinmap:context (spinmap:Context): The Context that will deliver an instance of a function that delivers the target resource from a source resource (?sourceResource).

Return type

Function body

SELECT (spin:eval(?targetExpr, spinmap:source, ?arg1) AS ?result)
WHERE {
    BIND (spl:object(?context, spinmap:target) AS ?targetExpr) .
}

spinmapl:buildURI (spin:Function)

A variation of spif:buildURI that can be used in conjunction with SPINMap. This takes the template as second argument, making it possible to enter a template that uses {?1} from the values of the first parameter.

Arguments

sp:arg1: The value to insert into the template at {?1}.
arg:template (xsd:string): The URI template, referencing the value to insert as {?1}.

Return type

Function body

SELECT ?result
WHERE {
    BIND (spif:buildURI(?template, ?arg1) AS ?result) .
}

spinmapl:buildURI1 (spinmap:TargetFunction)

Builds a new URI using the value of a given property (?arg1) from a given subject (?source) and a given template (?template). The template may reference the value of the property using {?1}.

Arguments

sp:arg1 (rdf:Property): The property to get the value of.
spinmap:source (rdfs:Resource): The source resource.
spinmapl:template (xsd:string): The template string, "ex:Instance-{?1}".

Return type

Function body

SELECT (IRI(?uri) AS ?result)
WHERE {
    BIND (spl:object(?source, ?arg1) AS ?value) .
    BIND (spif:buildURI(?template, ?value) AS ?uri) .
}

spinmapl:buildURI2 (spinmap:TargetFunction)

Builds URIs of the target resources using values of two given properties (?arg1 and ?arg2) for the source resources and a given template (?template). The template may reference the values of the properties using {?1} and {?2} respectively.

Arguments

sp:arg1 (rdf:Property): The first property to get the value of.
sp:arg2 (rdf:Property): The second property.
spinmap:source (rdfs:Resource): The source resource.
spinmapl:template (xsd:string): The template string, "ex:Instance-{?1}".

Return type

Function body

SELECT (IRI(?uri) AS ?result)
WHERE {
    BIND (spl:object(?source, ?arg1) AS ?value1) .
    BIND (spl:object(?source, ?arg2) AS ?value2) .
    BIND (spif:buildURI(?template, ?value1, ?value2) AS ?uri) .
}

spinmapl:buildURI3 (spinmap:TargetFunction)

Builds URIs of the target resources using values of three given properties (?arg1, ?arg2 and ?arg3) for the source resources and a given template (?template). The template may reference the values of the properties using {?1}, {?2} and {?3} respectively.

Arguments

sp:arg1 (rdf:Property): The first property to get the value of.
sp:arg2 (rdf:Property): The second property.
sp:arg3 (rdf:Property): The third property.
spinmap:source (rdfs:Resource): The source resource.
spinmapl:template (xsd:string): The template string, "ex:Instance-{?1}".

Return type

Function body

SELECT (IRI(?uri) AS ?result)
WHERE {
    BIND (spl:object(?source, ?arg1) AS ?value1) .
    BIND (spl:object(?source, ?arg2) AS ?value2) .
    BIND (spl:object(?source, ?arg3) AS ?value3) .
    BIND (spif:buildURI(?template, ?value1, ?value2, ?value3) AS ?uri) .
}

spinmapl:buildURI4 (spinmap:TargetFunction)

Builds URIs of the target resources using values of four given properties (?arg1, ?arg2, ?arg3 and ?arg4) for the source resources and a given template (?template). The template may reference the values of the properties using {?1}, {?2}, {?3} and {?4} respectively.

Arguments

sp:arg1 (rdf:Property): The first property to get the value of.
sp:arg2 (rdf:Property): The second property.
sp:arg3 (rdf:Property): The third property.
sp:arg4 (rdf:Property): The forth property.
spinmap:source (rdfs:Resource): The source resource.
spinmapl:template (xsd:string): The template string, "ex:Instance-{?1}".

Return type

Function body

SELECT (IRI(?uri) AS ?result)
WHERE {
    BIND (spl:object(?source, ?arg1) AS ?value1) .
    BIND (spl:object(?source, ?arg2) AS ?value2) .
    BIND (spl:object(?source, ?arg3) AS ?value3) .
    BIND (spl:object(?source, ?arg4) AS ?value4) .
    BIND (spif:buildURI(?template, ?value1, ?value2, ?value3, ?value4) AS ?uri) .
}

spinmapl:buildURI5 (spinmap:TargetFunction)

Builds URIs of the target resources using values of five given properties (?arg1, ?arg2, ?arg3, ?arg4 and ?arg5) for the source resources and a given template (?template). The template may reference the values of the properties using {?1}, {?2}, {?3}, {?4} and {?5} respectively.

Arguments

sp:arg1 (rdf:Property): The first property to get the value of.
sp:arg2 (rdf:Property): The second property.
sp:arg3 (rdf:Property): The third property.
sp:arg4 (rdf:Property): The forth property.
sp:arg5 (rdf:Property): The firth property.
spinmap:source (rdfs:Resource): The source resource.
spinmapl:template (xsd:string): The template string, "ex:Instance-{?1}".

Return type

Function body

SELECT (IRI(?uri) AS ?result)
WHERE {
    BIND (spl:object(?source, ?arg1) AS ?value1) .
    BIND (spl:object(?source, ?arg2) AS ?value2) .
    BIND (spl:object(?source, ?arg3) AS ?value3) .
    BIND (spl:object(?source, ?arg4) AS ?value4) .
    BIND (spl:object(?source, ?arg5) AS ?value5) .
    BIND (spif:buildURI(?template, ?value1, ?value2, ?value3, ?value4, ?value5) AS ?uri) .
}

spinmapl:changeNamespace (spinmap:TargetFunction)

Replaces the namespace of the source URIs by a given target namespace to create URIs of the target resources.

Arguments

spinmap:source (rdfs:Resource): The source resource.
spinmapl:targetNamespace (xsd:string): The target namespace.

Return type

Function body

SELECT ?target
WHERE {
    BIND (afn:localname(?source) AS ?localName) .
    BIND (IRI(CONCAT(?targetNamespace, ?localName)) AS ?target) .
}

Examples

spinmapl:changeNamespace(owl:Thing, "http://example.org/test#")
Result:  http://example.org/test#Thing

spinmapl:composeURI (spinmap:TargetFunction)

Builds URIs of the target resources using the local name of the source resources and a template given as ?template. The template may reference the value of the local name of a source resource using {?1}.

Arguments

spinmap:source (rdfs:Resource): The source resource.
spinmapl:template (xsd:string): The template string, "ex:Instance-{?1}".

Return type

Function body

SELECT (IRI(?uri) AS ?result)
WHERE {
    BIND (spif:localName(?source) AS ?value) .
    BIND (spif:buildURI(?template, ?value) AS ?uri) .
}

spinmapl:concatWithSeparator (spin:Function)

Creates the value(s) for the target property by concatenating the value(s) of the source properties as provided by the arguments (?arg1) and (?arg2) with a given separator in between (?separator).

Arguments

sp:arg1: The first value to concatenate.
sp:arg2: The second value to concatenate.
spinmapl:separator (xsd:string): The separator to put between the two values.

Return type

Function body

SELECT (xsd:string(?untyped) AS ?result)
WHERE {
    BIND (CONCAT(xsd:string(?arg1), ?separator, xsd:string(?arg2)) AS ?untyped) .
}

spinmapl:constantResource (spin:Function)

Gives the target property values that are equal to a constant resource provided as (?result) argument. This can be used to create a constant value for the target whenever a given (?arg1) property of the source has a value.

Arguments

sp:arg1: The input value (will be ignored).
spinmapl:result (rdfs:Resource): The result resource.

Function body

SELECT ?result
WHERE {
}

spinmapl:fixedLengthPathParent (spin:Function)

Creates a value for the target property by removing a set number of characters given as ?segmentLength argument from the end of the values of the source property specified as (?arg1) argument. This can be used to derive a �parent� value from a �child� path expression, e.g., parent of �W01020� is �W010�. Useful when parsing hierarchies where hierarchical relationships are encoded in the identifiers or �hierarchical path strings�. Note that this function preserves the original datatype of the input value for the result.

Arguments

sp:arg1 (xsd:string): The path expression, e.g. "W010203"
spinmapl:segmentLength (xsd:integer): The number of characters to remove from the end of the input string.

Return type

Function body

SELECT ?result
WHERE {
    {
        BIND (STRLEN(str(?arg1)) AS ?length) .
        FILTER (?length > ?segmentLength) .
    } .
    BIND (datatype(?arg1) AS ?dt) .
    BIND (fn:substring(str(?arg1), 1, (?length - ?segmentLength)) AS ?substr) .
    BIND (IF(bound(?dt), spif:cast(?substr, ?dt), ?substr) AS ?result) .
}

Examples

spinmapl:fixedLengthPathParent("W010203", 2)
Result:  W0102

spinmapl:fixedLengthPathParentTarget (spin:Function)

Gets the parent of a path expression (using the function fixedLengthPathParent) and finds a source instance with a matching value for a given property. Then it finds the target resource for that source instance.

Arguments

sp:arg1 (xsd:string): The path expression.
spinmapl:context (spinmap:Context): The context to use for deriving the target from the source instance.
spinmapl:predicate (rdf:Property): The predicate that holds the parent path value in the source instance.
spinmapl:segmentLength (xsd:integer): The number of characters to remove from the end of the path expression.

Return type

Function body

SELECT (spinmap:targetResource(?source, ?context) AS ?target)
WHERE {
    BIND (spinmapl:fixedLengthPathParent(?arg1, ?segmentLength) AS ?parentName) .
    FILTER bound(?parentName) .
    BIND (spl:subject(?predicate, ?parentName) AS ?source) .
    FILTER bound(?source) .
}

spinmapl:pathEnd (spin:Function)

Takes a path expression such as "World > Europe > Germany" provided as values of ?arg1 and a ?separator such as �>� and returns the last element, e.g. "Germany" .

Arguments

sp:arg1 (xsd:string): The path expression.
spinmapl:separator (xsd:string): The separator of path elements. Elements will be trimmed for white spaces, so the separator does not need to specify them.

Return type

Function body

SELECT (IF(bound(?last), spif:trim(smf:subString(?arg1, (?last + 1))), ?arg1) AS ?result)
WHERE {
    BIND (spif:lastIndexOf(?arg1, ?separator) AS ?last) .
}

spinmapl:pathParent (spin:Function)

Takes a path expression such as "World > Europe > Germany" provided as values of ?arg1 and a ?separator such as �>� and returns the last but one element, e.g. "Europe".

Arguments

sp:arg1 (xsd:string): The path expression.
spinmapl:separator (xsd:string): The separator of path elements. Elements will be trimmed for white spaces, so the separator does not need to specify them.

Return type

Function body

SELECT ?parent
WHERE {
    BIND (spif:lastIndexOf(?arg1, ?separator) AS ?last) .
    FILTER bound(?last) .
    BIND (spif:lastIndexOf(?arg1, ?separator, (?last - 1)) AS ?last1) .
    BIND (IF(bound(?last1), (?last1 + 1), 0) AS ?start) .
    BIND (spif:trim(smf:subString(?arg1, ?start, ?last)) AS ?parent) .
}

Examples

spinmapl:pathParent("World > Europe > Germany", ">")
Result:  Europe
spinmapl:pathParent("Europe,Germany", ",")
Result:  Europe
spinmapl:pathParent("World", ">")
Result:  Invalid.

spinmapl:pathParentTarget (spin:Function)

Gets the parent of a path expression (using the function pathParent) and finds a source instance with a matching value for a given property. Then it finds the target resource for that source instance. This is a highly specialized function for a design pattern often used in spreadsheets, where one column contains the full path expression, and the other contains the name of the item.

Arguments

sp:arg1 (xsd:string): The path expression.
spinmapl:context (spinmap:Context): The context to use for deriving the target from the source instance.
spinmapl:predicate (rdf:Property): The predicate that holds the parent path value in the source instance.
spinmapl:separator (xsd:string): The path separator, e.g. ">".

Return type

Function body

SELECT ?target
WHERE {
    BIND (spinmapl:pathParent(?arg1, ?separator) AS ?parentName) .
    FILTER bound(?parentName) .
    BIND (spl:subject(?predicate, ?parentName) AS ?source) .
    BIND (spinmap:targetResource(?source, ?context) AS ?target) .
}

spinmapl:relatedObjectContext (spinmap:TargetFunction)

This function uses a property given as ?predicate argument to find resources related to the resources in the source class as objects in a triple {?source ?predicate ?object}. It then applies mapping for these �related objects� as specified in a context given as ?context argument to build the target resource. This is useful if the source instances we want to use for the target are one step away from the current source instances, but we want to give the targets some of the properties of the current source instances.

Arguments

spinmapl:context (spinmap:Context): The Context to apply to the related source resource to create the target resource.
spinmapl:predicate (rdf:Property): The predicate that connects resources from the source class to related resources.
spinmap:source (rdfs:Resource): The source resource.

Function body

SELECT (spinmap:targetResource(?object, ?context) AS ?result)
WHERE {
    ?source ?predicate ?object .
}

spinmapl:relatedSubjectContext (spinmap:TargetFunction)

This function uses a property given as ?predicate argument to find resources related to the resources in the source class as subjects in a triple {?subject ?predicate ?source}. It then applies mapping for these related subjects as specified in a context given as ?context argument to build target resources. This is useful if the source instances we want to use for the target are one step away from the current source instances, but we want to give the targets some of the properties of the current source instances.

Arguments

spinmapl:context (spinmap:Context): The SPINMap Context to apply to the related source resource to create the target resource.
spinmapl:predicate (rdf:Property): The predicate that connects resources from the source class to related resources.
spinmap:source (rdfs:Resource): The source resource.

Function body

SELECT (spinmap:targetResource(?subject, ?context) AS ?result)
WHERE {
    ?subject ?predicate ?source .
}

spinmapl:resourceWithPrimaryKey (spin:Function)

Takes a value and builds a URI for an instance of a given class, using the primary key defined for that class.

Arguments

sp:arg1: The value to build the primary key with.
arg:class (rdfs:Class): The class (that has a primary key).

Return type

Function body

SELECT ?resource
WHERE {
    BIND (swa:primaryKeyURIStart(?class) AS ?uriStart) .
    BIND (IRI(CONCAT(?uriStart, ENCODE_FOR_URI(xsd:string(?arg1)))) AS ?resource) .
}

spinmapl:resourceWithValue (spin:Function)

Takes a value (?arg1) and a property (?predicate), as well as an optional type, and returns a resource that has the given value as object for the predicate. For example, this can be used to find an instance of the class Country that has "Australia" as its label.

Arguments

sp:arg1: The value to match against.
spinmapl:predicate (rdf:Property): The property that must be used in the result resource.
spinmapl:type (rdfs:Class): [Optional] The (optional) type of the result object, to narrow down the search space.

Return type

Function body

SELECT ?subject
WHERE {
    ?subject ?predicate ?arg1 .
    ?t (rdfs:subClassOf)* ?type .
    ?subject a ?t .
}

spinmapl:self (spinmap:TargetFunction)

A simple function that returns the source instance itself, reusing exactly the same URIs and blank node identifiers.

Arguments

spinmap:source (rdfs:Resource): The source resource.

Return type

Function body

SELECT ?source
WHERE {
}

spinmapl:selfJoin (spin:Function)

Can be used to construct "self-join" matches, where the result is a resource from the target ontology.

Arguments

sp:arg1: The value(s) that the source instance must have for the predicate.
spinmapl:context (spinmap:Context): The context to create the result resource with.
spinmapl:predicate (rdf:Property): The predicate to look for.

Function body

SELECT (spinmap:targetResource(?source, ?context) AS ?target)
WHERE {
    ?source ?predicate ?arg1 .
    ?context spinmap:sourceClass ?sourceClass .
    ?type (rdfs:subClassOf)* ?sourceClass .
    ?source a ?type .
}

spinmapl:toBoolean (spin:Function)

Takes true/false or yes/no values (ignoring case) and maps them to true/false as xsd:boolean literals.

Arguments

sp:arg1 (xsd:string): The (string) value to convert. Should be "yes" or "no".

Return type

Function body

SELECT ?result
WHERE {
    BIND (LCASE(str(?arg1)) AS ?str) .
    BIND (IF((?str IN ("yes", "true")), true, IF((?str IN ("no", "false")), false, ?none)) AS ?result) .
}

spinmapl:usePrimaryKey (spinmap:TargetFunction)

Builds a URI based on a primary key definition. Assumes that the target class of the given SPINMap Context has an spl:PrimaryKeyPropertyConstraint - either directly or via class inheritance. There also must be a 1-1 mapping associated with that Context that produces values for primary key property. The function runs that mapping to produce the value of the primary key property for the given source instance and then uses that value to build a URI, using the uriStart of the primary key declaration.

Arguments

spinmapl:context (spinmap:Context): The SPINMap Context to apply to the related source resource to create the target resource.
spinmap:source (rdfs:Resource): The source resource.

Function body

SELECT ?uri
WHERE {
    {
        {
            ?context spinmap:targetClass ?targetClass .
            BIND (swa:primaryKeyProperty(?targetClass) AS ?targetProperty) .
            BIND (swa:primaryKeyURIStart(?targetClass) AS ?uriStart) .
            FILTER (bound(?uriStart) && bound(?targetProperty)) .
        } .
        ?mapping spinmap:targetPredicate1 ?targetProperty .
        ?mapping spinmap:context ?context .
        ?mapping a spinmap:Mapping-1-1 .
        ?mapping spinmap:sourcePredicate1 ?sourceProperty .
        ?mapping spinmap:expression ?expression .
        ?source ?sourceProperty ?sourceValue .
        BIND (spin:eval(?expression, sp:arg1, ?sourceValue) AS ?targetValue) .
        FILTER bound(?targetValue) .
    } .
    BIND (IRI(CONCAT(?uriStart, ENCODE_FOR_URI(xsd:string(?targetValue)))) AS ?uri) .
}

spl:hasArgument (spin:Function)

Checks if a given module class (?module) has at least one declared spl:Argument.

Arguments

spl:class (spin:Module): The module class to check.

Return type

Function body

ASK WHERE {
    ?class (rdfs:subClassOf)* ?superClass .
    ?superClass spin:constraint ?con .
    ?con a spl:Argument .
}

spl:hasPrimaryKey (spin:Function)

Checks if a given class has a declared primary key, using spl:PrimaryKeyPropertyConstraint.

Arguments

arg:class (rdfs:Class): The class to get the primary key of.

Return type

Function body

ASK WHERE {
    BIND (spl:primaryKeyProperty(?class) AS ?primaryKey) .
    FILTER bound(?primaryKey) .
}

spl:hasValue (spin:Function)

Checks whether a given resource (?arg1) has a given value (?arg3) for a given property (?arg2) or one of the sub-properties of it.

Arguments

sp:arg1 (rdfs:Resource): the subject that is expected to have the value
sp:arg2 (rdf:Property): the property that is expected to hold the value
sp:arg3: the expected value

Return type

Function body

ASK WHERE {
    ?p (rdfs:subPropertyOf)* ?arg2 .
    ?arg1 ?p ?arg3 .
}

spl:hasValueOfType (spin:Function)

Checks whether a given subject (?arg1) has at least one value of a given type (?arg3) for a given property (?arg2) or one of its sub-properties.

Arguments

sp:arg1 (rdfs:Resource): the subject that is expected to have the value
sp:arg2 (rdf:Property): the expected property
sp:arg3 (rdfs:Class): the type to match against

Return type

Function body

ASK WHERE {
    ?p (rdfs:subPropertyOf)* ?arg2 .
    ?arg1 ?p ?value .
    FILTER spl:instanceOf(?value, ?arg3) .
}

spl:instanceOf (spin:Function)

Checks whether a given resource (?arg1) has a given type (?arg2). In order to fulfill this condition, there must either be a triple ?arg1 rdf:type ?arg2, or ?instance rdf:type ?subClass where ?subClass is a subclass of ?arg2. If the first argument is a literal, then the second argument must be the matching XSD datatype.

Arguments

sp:arg1 (rdfs:Resource): the instance being tested
sp:arg2 (rdfs:Class): the type that the instance must have

Return type

Function body

ASK WHERE {
    {
        {
            FILTER (isIRI(?arg1) || isBlank(?arg1)) .
        } .
        ?class (rdfs:subClassOf)* ?arg2 .
        ?arg1 a ?class .
    }
    UNION
    {
        {
            FILTER isLiteral(?arg1) .
        } .
        BIND (datatype(?arg1) AS ?datatype) .
        FILTER (((?datatype = ?arg2) || (?arg2 = rdfs:Literal)) || (((!bound(?datatype)) || (rdf:langString = ?datatype)) && (?arg2 = xsd:string))) .
    } .
}

Examples

spl:instanceOf("test"@en, xsd:string)
Result:  true
spl:instanceOf(owl:Thing, rdfs:Class)
Result:  true
spl:instanceOf(owl:versionInfo, rdfs:Class)
Result:  false
spl:instanceOf(owl:Restriction, rdfs:Class)
Result:  true
spl:instanceOf("test", rdfs:Literal)
Result:  true
spl:instanceOf(owl:Thing, rdfs:Literal)
Result:  false
spl:instanceOf("test", xsd:string)
Result:  true
spl:instanceOf("test", xsd:integer)
Result:  false
spl:instanceOf("test", xsd:string)
Result:  true

spl:isPrimaryKeyPropertyOfInstance (spin:Function)

Checks if a given property is the primary key of a given instance.

Arguments

arg:instance (rdfs:Resource): The instance to check.
arg:property (rdf:Property): The property that may or may not be the primary key.

Return type

Function body

ASK WHERE {
    ?instance a ?type .
    BIND (spl:primaryKeyProperty(?type) AS ?pk) .
    FILTER (?property = ?pk) .
}

spl:isUntypedLiteral (spin:Function)

Checks whether a given literal is untyped. This function was introduced because the built-in datatype operand in SPARQL casts untyped literals to xsd:string, making it impossible to check it this way. This function here uses a work-around using sameTerm instead.

Arguments

sp:arg1 (rdfs:Literal): The literal to test.

Return type

Function body

ASK WHERE {
    FILTER (isLiteral(?arg1) && (!sameTerm(?arg1, xsd:string(?arg1)))) .
}

spl:max (spin:Function)

Takes two arguments and returns the larger one of them.

Arguments

sp:arg1 (rdfs:Literal): The first argument.
sp:arg2 (rdfs:Literal): The second argument.

Return type

Function body

SELECT ?result
WHERE {
    BIND (IF((?arg1 > ?arg2), ?arg1, ?arg2) AS ?result) .
}

spl:min (spin:Function)

Takes two arguments and returns the smaller one of them.

Arguments

sp:arg1 (rdfs:Literal): The first argument.
sp:arg2 (rdfs:Literal): The second argument.

Return type

Function body

SELECT ?result
WHERE {
    BIND (IF((?arg1 < ?arg2), ?arg1, ?arg2) AS ?result) .
}

spl:object (spin:Function)

Gets the object of a given subject (?arg1) / predicate (?arg2) combination. Note that if multiple values are present then the result might be unpredictably random. Furthermore, if one of the arguments is unbound, it will return the first match of the resulting SPO pattern. These scenarios are strongly discouraged but remain left supported for backward compatibility reasons.

Arguments

sp:arg1 (rdfs:Resource): The subject to get the object from.
sp:arg2 (rdf:Property): The predicate to get the object of.

Function body

SELECT ?object
WHERE {
    ?arg1 ?arg2 ?object .
}

Examples

SELECT ?value
WHERE {
    GRAPH <http://spinrdf.org/spl> {
        BIND (spl:object(spl:Argument, rdfs:label) AS ?value) .
    } .
}
Result:  Argument
spl:object(owl:versionInfo, owl:versionInfo)
Result:  Invalid.

spl:objectCount (spin:Function)

Gets the number of values of a given property (?arg2) at a given subject (?arg1). The result is the number of matches of (?arg1, ?arg2, ?object).

Arguments

sp:arg1 (rdfs:Resource): the subject to get the number of objects of
sp:arg2 (rdf:Property): the property to get the number of values of

Return type

Function body

SELECT (COUNT(?object) AS ?result)
WHERE {
    ?arg1 ?arg2 ?object .
}

spl:objectInGraph (spin:Function)

Gets the object of a given subject (?arg1) / predicate (?arg2) combination in a given graph ?arg3. Note that if multiple values are present then the result might be unpredictably random.

Arguments

sp:arg1 (rdfs:Resource): The subject to get the object from.
sp:arg2 (rdf:Property): The predicate to get the object of.
sp:arg3 (rdfs:Resource): The graph to query in.

Function body

SELECT ?object
WHERE {
    GRAPH ?arg3 {
        ?arg1 ?arg2 ?object .
    } .
}

spl:objectSubProp (spin:Function)

Gets the object of a given subject (?arg1) / predicate (?arg2) combination, also taking the sub-properties of ?arg2 into account. Note that if multiple values are present then the result might be unpredictably random.

Arguments

sp:arg1 (rdfs:Resource): The subject to get the object from.
sp:arg2 (rdf:Property): The predicate to get the object of (including sub-properties of it).

Function body

SELECT ?object
WHERE {
    ?property (rdfs:subPropertyOf)* ?arg2 .
    ?arg1 ?property ?object .
}

spl:primaryKeyProperty (spin:Function)

Gets the primary key property declared for a given class, using spl:PrimaryKeyPropertyConstraint.

Arguments

arg:class (rdfs:Class): The class to get the primary key of.

Return type

Function body

SELECT ?property
WHERE {
    ?class (rdfs:subClassOf)* ?type .
    ?type spin:constraint ?constraint .
    ?constraint a spl:PrimaryKeyPropertyConstraint .
    ?constraint arg:property ?property .
}

spl:primaryKeyURIStart (spin:Function)

Gets the URI start declared as part of a primary key declaration for a given class, using spl:PrimaryKeyPropertyConstraint.

Arguments

arg:class (rdfs:Class): The class to get the primary key of.

Return type

Function body

SELECT ?result
WHERE {
    ?class (rdfs:subClassOf)* ?type .
    ?type spin:constraint ?constraint .
    ?constraint a spl:PrimaryKeyPropertyConstraint .
    ?constraint arg:uriStart ?result .
}

spl:relevantPropertyAtClass (spin:MagicProperty)

A magic property that establishes a relationship between properties (left) and classes (right) to determine which properties are "relevant" for the class. Relevant means that they have the class in their domain and/or restrictions, including superclasses and sub-properties (unless they define their own domain). Domains consisting of an owl:unionOf are also handled. Note that the performance of the body of this magic property has been optimized for the case in which the class is given, so ideally use this for queries such as ?property spl:relevantPropertyAtClass skos:Concept .

Arguments

sp:arg1 (rdf:Property): The property.

Return type

Function body

SELECT DISTINCT ?class
WHERE {
    ?class (rdfs:subClassOf)* ?superClass .
    {
        ?property rdfs:domain ?superClass .
    }
    UNION
    {
        ?superClass owl:onProperty ?property .
    }
    UNION
    {
        ?listSegment rdf:first ?superClass .
        ?list (rdf:rest)* ?listSegment .
        ?property rdfs:domain/owl:unionOf ?list .
    } .
    ?arg1 (rdfs:subPropertyOf)* ?property .
    FILTER ((?arg1 = ?property) || NOT EXISTS {
        ?arg1 rdfs:domain ?anyDomain .
    }) .
    FILTER isIRI(?class) .
}

spl:subClassOf (spin:Function)

Checks whether a given class (?arg1) is a (transitive) sub-class of another class (?arg2).

Arguments

sp:arg1 (rdfs:Class): The potential sub-class.
sp:arg2 (rdfs:Class): The potential super-class.

Return type

Function body

ASK WHERE {
    ?arg1 (rdfs:subClassOf)* ?arg2 .
}

spl:subPropertyOf (spin:Function)

Checks whether a given property (?arg1) is a (transitive) sub-property of another property (?arg2).

Arguments

sp:arg1 (rdf:Property): The potential sub-property.
sp:arg2 (rdf:Property): The potential super-property.

Return type

Function body

ASK WHERE {
    ?arg1 (rdfs:subPropertyOf)* ?arg2 .
}

spl:subject (spin:Function)

Gets the "first" subject of a given predicate (?arg1)/object (?arg2) combination. Note that if multiple values are present then the result might be unpredictably random.

Arguments

sp:arg1 (rdf:Property): The predicate.
sp:arg2: The object.

Function body

SELECT ?subject
WHERE {
    ?subject ?arg1 ?arg2 .
}

spl:subjectCount (spin:Function)

Gets the number of values of a given property (?arg1) at a given object (?arg2). The result is the number of matches of (?subject, ?arg1, ?arg2).

Arguments

sp:arg1 (rdf:Property): the predicate to get the number of subjects of
sp:arg2: the object to get the number of subjects of

Return type

Function body

SELECT (COUNT(?subject) AS ?result)
WHERE {
    ?subject ?arg1 ?arg2 .
}

spl:subjectInGraph (spin:Function)

Gets the "first" subject of a given predicate (?arg1)/object (?arg2) combination in a given graph (?arg3). Note that if multiple values are present then the result might be unpredictably random.

Arguments

sp:arg1 (rdf:Property): The predicate.
sp:arg2: The object.
sp:arg3 (rdfs:Resource): The graph to operate on.

Function body

SELECT ?subject
WHERE {
    GRAPH ?arg3 {
        ?subject ?arg1 ?arg2 .
    } .
}

spr:aggregateCol (spin:Function)

Applies the spr:Aggregator ?arg1 to all rows of column ?arg3 of spr:Table ?arg2.

Arguments

sp:arg1 (spr:Aggregator): The aggregator to perform.
sp:arg2 (spr:Table): The spr:Table to iterate over.
sp:arg3 (xsd:integer): The column index.

Function body

SELECT ?result
WHERE {
    ?arg1 spr:stepFunction ?stepFunction .
    ?arg1 spr:startValue ?startValue .
    OPTIONAL {
        ?arg1 spr:resultFunction ?resultFunction .
    } .
    BIND (spr:rowCount(?arg2) AS ?rowCount) .
    BIND (spr:visitCol(?arg2, ?arg3, 0, (?rowCount - 1), ?stepFunction, ?startValue) AS ?stepped) .
    BIND (IF(bound(?resultFunction), spif:invoke(?resultFunction, ?stepped, ?rowCount), ?stepped) AS ?result) .
}

spr:aggregateRow (spin:Function)

Applies the spr:Aggregator ?arg1 to all columns of row ?arg3 of spr:Table ?arg2.

Arguments

sp:arg1 (spr:Aggregator): The aggregator to perform.
sp:arg2 (spr:Table): The spr:Table to iterate over.
sp:arg3 (xsd:integer): The row index.

Function body

SELECT ?result
WHERE {
    ?arg1 spr:stepFunction ?stepFunction .
    ?arg1 spr:startValue ?startValue .
    OPTIONAL {
        ?arg1 spr:resultFunction ?resultFunction .
    } .
    BIND (spr:colCount(?arg2) AS ?colCount) .
    BIND (spr:visitRow(?arg2, ?arg3, 0, (?colCount - 1), ?stepFunction, ?startValue) AS ?stepped) .
    BIND (IF(bound(?resultFunction), spif:invoke(?resultFunction, ?stepped, ?colCount), ?stepped) AS ?result) .
}

spr:cell (spin:Function)

Gets the cell value of a given Table (?arg1) at a given row (?arg2) and column (?arg3).

Arguments

sp:arg1 (spr:Table): The spr:Table to get the cell value of.
sp:arg2 (xsd:integer): The row index, starting at 0.
sp:arg3 (xsd:integer): The column index, starting at 0.

Function body

SELECT ?result
WHERE {
    ?arg1 a ?tableClass .
    ?tableClass spr:cellFunction ?function .
    BIND (spif:invoke(?function, ?arg1, ?arg2, ?arg3) AS ?result) .
}

spr:colCells (spin:MagicProperty)

Iterates over all rows of a given table (left side, ?arg1) at column ?arg2 and binds the variable on the right with the cell values. The second variable on the right may be bound to the row index as well.

Arguments

sp:arg1 (spr:Table): The spr:Table to get the values for.
sp:arg2 (xsd:integer): The column index, starting at zero.

Function body

SELECT ?value ?row
WHERE {
    ?arg1 spr:rowIndices ?row .
    BIND (spr:cell(?arg1, ?row, ?arg2) AS ?value) .
}

spr:colCount (spin:Function)

Gets the number of columns of a given result set.

Arguments

sp:arg1 (spr:TableClass): The table to get the number of columns of.

Return type

Function body

SELECT ?result
WHERE {
    ?arg1 a ?tableClass .
    ?tableClass spr:colCountFunction ?function .
    BIND (spif:invoke(?function, ?arg1) AS ?result) .
}

spr:colIndices (spin:MagicProperty)

Iterates over all columns of a given table (left side, ?arg1) and binds the variable on the right with the index of the columns.

Arguments

sp:arg1 (spr:Table): The spr:Table to get the row indexes of.

Function body

SELECT ?index
WHERE {
    BIND ((spr:colCount(?arg1) - 1) AS ?lastIndex) .
    ?index tops:for ( 0 ?lastIndex ) .
}

spr:colName (spin:Function)

Gets the name of a column in a given result set. The name is usually derived from the variable name, but may also originate from spin:Columns attached to the table data provider.

Arguments

sp:arg1 (spr:Table): The table to get the column name for.
sp:arg2 (xsd:integer): The column index, starting at zero.

Return type

Function body

SELECT ?result
WHERE {
    ?arg1 a ?tableClass .
    ?tableClass spr:colNameFunction ?function .
    BIND (spif:invoke(?function, ?arg1, ?arg2) AS ?result) .
}

spr:colType (spin:Function)

Gets the (data) type of a column, if this information is present. The datatype may be derived from spin:Columns attached to the table data provider.

Arguments

sp:arg1 (spr:Table): The table to get the column name for.
sp:arg2 (xsd:integer): The column index, starting at zero.

Return type

Function body

SELECT ?result
WHERE {
    ?arg1 a ?tableClass .
    ?tableClass spr:colTypeFunction ?function .
    BIND (spif:invoke(?function, ?arg1, ?arg2) AS ?result) .
}

spr:colWidth (spin:Function)

Gets the width (in pixels) of a given column. This may have been derived from spin:Columns attached to the table data provider.

Arguments

sp:arg1 (spr:Table): The table to get the column name for.
sp:arg2 (xsd:integer): The column index, starting at zero.

Return type

Function body

SELECT ?result
WHERE {
    ?arg1 a ?tableClass .
    ?tableClass spr:colWidthFunction ?function .
    BIND (spif:invoke(?function, ?arg1, ?arg2) AS ?result) .
}

spr:colWithName (spin:Function)

Gets the index of a column with a given name.

Arguments

sp:arg1 (spr:Table): The spr:Table to iterate over.
sp:arg2 (xsd:string): The name of the col to get.

Return type

Function body

SELECT ?colIndex
WHERE {
    {
        ?arg1 spr:colIndices ?colIndex .
        BIND (spr:colName(?arg1, ?colIndex) AS ?colName) .
    } .
    FILTER (?colName = ?arg2) .
}

spr:hasCell (spin:Function)

Checks if there is a cell value in a given Table (?arg1) at a given row (?arg2) and column (?arg3).

Arguments

sp:arg1 (spr:Table): The spr:Table to get the cell value of.
sp:arg2 (xsd:integer): The row index, starting at 0.
sp:arg3 (xsd:integer): The column index, starting at 0.

Return type

Function body

ASK WHERE {
    ?arg1 a ?tableClass .
    ?tableClass spr:cellFunction ?function .
    BIND (spif:invoke(?function, ?arg1, ?arg2, ?arg3) AS ?result) .
    FILTER bound(?result) .
}

spr:isEmpty (spin:Function)

Checks whether a given SPR table has zero rows.

Arguments

sp:arg1 (spr:Table): The spr:Table to get the number of rows for.

Return type

Function body

ASK WHERE {
    FILTER (spr:rowCount(?arg1) = 0) .
}

spr:rowCells (spin:MagicProperty)

Iterates over all columns of a given table (left side, ?arg1) at row ?arg2 and binds the variable on the right with the cell values. The second variable on the right may be bound to the column index as well.

Arguments

sp:arg1 (spr:Table): The spr:Table to get the values for.
sp:arg2 (xsd:integer): The row index, starting at zero.

Function body

SELECT ?value ?col
WHERE {
    ?arg1 spr:colIndices ?col .
    BIND (spr:cell(?arg1, ?arg2, ?col) AS ?value) .
}

spr:rowCount (spin:Function)

Gets the number of rows in a given table.

Arguments

sp:arg1 (spr:Table): The spr:Table to get the number of rows for.

Return type

Function body

SELECT ?result
WHERE {
    ?arg1 a ?tableClass .
    ?tableClass spr:rowCountFunction ?function .
    BIND (spif:invoke(?function, ?arg1) AS ?result) .
}

spr:rowIndices (spin:MagicProperty)

Iterates over all rows of a given table (left side, ?arg1) and binds the variable on the right with the index of the rows.

Arguments

sp:arg1 (spr:Table): The spr:Table to get the row indexes of.

Function body

SELECT ?index
WHERE {
    BIND ((spr:rowCount(?arg1) - 1) AS ?lastIndex) .
    ?index tops:for ( 0 ?lastIndex ) .
}

spr:visitCol (spin:Function)

Visits a given column ?arg2 of Table ?arg1 with a given spr:AggregatorStepFunction (?arg5) and then calls itself recursively until the last value index (?arg4) has been reached. ?arg6 is the result of the previous step.

Arguments

sp:arg1 (spr:Table): The spr:Table to iterate over.
sp:arg2 (xsd:integer): The row to iterate over.
sp:arg3 (xsd:integer): The current step index.
sp:arg4 (xsd:integer): The max number of steps to make.
sp:arg5 (spin:Function): The step function.
sp:arg6: The current aggregate value.

Function body

SELECT ?result
WHERE {
    BIND (spr:cell(?arg1, ?arg3, ?arg2) AS ?value) .
    BIND (IF(bound(?value), spif:invoke(?arg5, ?arg6, ?value), ?arg6) AS ?next) .
    BIND (IF((?arg3 < ?arg4), spr:visitCol(?arg1, ?arg2, (?arg3 + 1), ?arg4, ?arg5, ?next), ?next) AS ?result) .
}

spr:visitRow (spin:Function)

Visits a given row ?arg2 of Table ?arg1 with a given spr:AggregatorStepFunction (?arg5) and then calls itself recursively until the last value index (?arg4) has been reached. ?arg6 is the result of the previous step.

Arguments

sp:arg1 (spr:Table): The spr:Table to iterate over.
sp:arg2 (xsd:integer): The row to iterate over.
sp:arg3 (xsd:integer): The current step index.
sp:arg4 (xsd:integer): The max number of steps to make.
sp:arg5 (spin:Function): The step function.
sp:arg6: The current aggregate value.

Function body

SELECT ?result
WHERE {
    BIND (spr:cell(?arg1, ?arg2, ?arg3) AS ?value) .
    BIND (IF(bound(?value), spif:invoke(?arg5, ?arg6, ?value), ?arg6) AS ?next) .
    BIND (IF(((?arg3 + 1) < ?arg4), spr:visitRow(?arg1, ?arg2, (?arg3 + 1), ?arg4, ?arg5, ?next), ?next) AS ?result) .
}

swa:appName (spin:Function)

Gets the current SWA application name. This can be set in as context variable "swaAppName".

Return type

Function body

SELECT (ui:contextValue("swaAppName") AS ?result)
WHERE {
}

swa:categoryByNamespace (spin:Function)

Arguments

arg:resource (rdfs:Resource): The resource to categorize.

Function body

SELECT ?label
WHERE {
    BIND (afn:namespace(?resource) AS ?ns) .
    BIND (IRI(IF(STRENDS(?ns, "#"), SUBSTR(?ns, 1, (STRLEN(?ns) - 1)), ?ns)) AS ?graphURI) .
    BIND (COALESCE(swa:graphLabel(IRI(?ns)), swa:graphLabel(?graphURI), CONCAT("<", ?ns, ">")) AS ?label) .
}

swa:columnLabel (spin:Function)

Gets a column label based on a given spin:TableDataProvider. Tries to find the rdfs:label of a spin:Column with the provided index.

Arguments

arg:dataProvider (spin:TableDataProvider): [Optional] The data provider - may be null in which case the function returns unbound too.
arg:index (xsd:integer):

Function body

SELECT ?label
WHERE {
    {
        FILTER bound(?dataProvider) .
    } .
    GRAPH ui:unionGraph {
        ?dataProvider spin:column ?column .
        ?column spin:columnIndex ?index .
        ?column rdfs:label ?label .
    } .
}

swa:configGraph (spin:Function)

Gets the global UI config graph - <http://server.topbraidlive.org/dynamic/uiconfig>

Return type

Function body

SELECT ?result
WHERE {
    BIND (<http://server.topbraidlive.org/dynamic/uiconfig> AS ?result) .
}

swa:constraint (spin:MagicProperty)

For a given shape, gets all declared constraints, identified by their constraint component and (if applicable) their parameter value. Example usage: ?shape swa:constraint ( ?component ?value ) .

Arguments

sp:arg1 (rdfs:Resource): The shape to get the constraints of.

Function body

SELECT ?component ?value
WHERE {
    {
        {
            ?arg1 swa:constraintComponent ?component .
            BIND (swa:singleParameter(?component) AS ?predicate) .
            FILTER bound(?predicate) .
        } .
        ?arg1 ?predicate ?value .
    }
    UNION
    {
        ?arg1 swa:constraintComponent ?component .
        BIND (swa:singleParameter(?component) AS ?predicate) .
        FILTER (!bound(?predicate)) .
    } .
}

swa:constraintComponent (spin:MagicProperty)

For a given shape, gets the constraint components of all declared constraints. Example usage: ?shape swa:constraintComponent ?component .

Arguments

sp:arg1 (rdfs:Resource): The shape to get the constraints of.

Return type

Function body

SELECT DISTINCT ?component
WHERE {
    ?arg1 ?predicate ?value .
    ?parameter sh:path ?predicate .
    ?component sh:parameter ?parameter .
    FILTER spl:instanceOf(?component, sh:ConstraintComponent) .
}

swa:constraintLabel (spin:Function)

Gets a display label for a constraint at a shape, using any declared sh:labelTemplate where possible.

Arguments

arg:component (sh:ConstraintComponent): The sh:ConstraintComponent.
arg:parameter: [Optional] The (single) parameter value in cases such as sh:class, where multiple values may be present.
arg:shape (sh:Shape): The shape defining the constraint.

swa:countStringMatches (spin:Function)

Counts how many times the substring appears in the larger string.

Arguments

arg:string (xsd:string): The string to search in.
arg:subString (xsd:string): The sub-string that is expected to be part of the other string.

Return type


swa:countryCodeForLang (spin:Function)

Takes the lang of a given literal and picks a suitable country code for it. If it's a two-letter code then it tries to find the default one associated with the language using swa:defaultCountryCodeForLanguageCode. For 5-letter codes such as en-UK it simply returns the second part lower-cased.

Arguments

arg:lang (xsd:string): The lang code, either with 2 or 5 letters.

Return type

Function body

SELECT ?code
WHERE {
    BIND (IF((fn:string-length(?lang) = 2), swa:defaultCountryCodeForLanguageCode(?lang), spif:lowerCase(fn:substring(?lang, 4))) AS ?code) .
}

swa:createPropertyShapeURI (spin:Function)

Produces a "suggested" URI for a property shape at a given shape for a given predicate. Results will be of the form [SHAPE-URI]-[PREDICATE-LOCAL-NAME][-"inverse], possibly with "-0", "-1" etc appended to make them unique.

Arguments

arg:inverse (xsd:boolean): True to create an inverse.
arg:predicate (rdf:Property): The predicate to create a constraint for.
arg:shape (sh:Shape): The shape to add the constraint to (must be a URI).
arg:zindex (xsd:integer): [Optional] An optional index that will be used in recursive calls.

Return type

Function body

SELECT ?result
WHERE {
    BIND (CONCAT(str(?shape), "-", afn:localname(?predicate), IF(?inverse, "-inverse", "")) AS ?base) .
    BIND (IRI(IF(bound(?zindex), CONCAT(?base, "-", str(?zindex)), ?base)) AS ?iri) .
    BIND (IF(EXISTS {
        ?iri ?anyP ?anyO .
    }, swa:createPropertyShapeURI(?inverse, ?predicate, ?shape, COALESCE((?zindex + 1), 0)), ?iri) AS ?result) .
}

swa:dataGraph (spin:Function)

Gets the current data graph. By default this is simply the current query graph. Can be set to some other value using the context variable "dataGraph". This is used by the SWA form mechanism: a form may switch to a different query graph to collect schema information (properties, ranges etc), but some widgets need to return to the domain/instances model in call-backs (such as auto-complete).

Return type

Function body

SELECT (COALESCE(ui:contextValue("dataGraph"), ui:currentQueryGraph()) AS ?result)
WHERE {
}

swa:defaultOntology (spin:Function)

Gets the "default" owl:Ontology in the current query graph. This is simply returning the first that it finds, so the context should make sure that only one exists or - at least - that the graph is a MultiUnion where the most relevant match is in the base graph that will be queried first. If no owl:Ontology is found, it uses ui:currentQueryGraph() and if that's not bound either then it's making up a URI.

Return type

Function body

SELECT (COALESCE(?ontology, ui:currentQueryGraph(), <urn:x-error:no-ontology-found>) AS ?result)
WHERE {
    OPTIONAL {
        ?ontology a owl:Ontology .
    } .
}

swa:defaultPropertyShape (spin:Function)

Gets the default property shape URI for a given shape/property combination. This is the URI of the shape + "-" + the local name of the property.

Arguments

arg:property (rdf:Property): The path property.
arg:shape (sh:NodeShape): The shape or class to create the property shape for.

Return type

Function body

SELECT ?result
WHERE {
    BIND (IRI(CONCAT(str(?shape), "-", afn:localname(?property))) AS ?result) .
}

swa:directCompositeChild (spin:MagicProperty)

For a given parent resource (left hand side) this magic property delivers all "depending" objects declared via dash:composite. The right hand side of this magic property must be an unbound variable. Works only for sh:path expressions that are either IRIs or consist of a single inverse path with a named predicate, not arbitrary sh:paths.

Arguments

sp:arg1 (rdfs:Resource): The parent resource.

Return type

Function body

SELECT DISTINCT ?child
WHERE {
    ?arg1 swa:shapesForNode ?shape .
    ?shape sh:property ?propertyShape .
    ?propertyShape dash:composite true .
    ?propertyShape sh:path ?path .
    {
        FILTER isIRI(?path) .
        ?arg1 ?path ?child .
    }
    UNION
    {
        {
            ?path sh:inversePath ?inverse .
            FILTER isIRI(?inverse) .
        } .
        ?child ?inverse ?arg1 .
    } .
}

swa:directForm (spin:Function)

Gets a ui:instanceView of a class that has been marked to match id "form". This function needs to be called from within the ui:graph.

Arguments

arg:class (rdfs:Class): The class that the form is attached to.

Return type

Function body

SELECT ?form
WHERE {
    ?class ui:instanceView ?form .
    ?form ui:id ?ids .
    ?id spif:split ( ?ids " " ) .
    FILTER (?id = "form") .
}

swa:directFormInConfigGraph (spin:Function)

Gets a ui:instanceView of a class that has been marked to match id "form" in the ui:configGraph().

Arguments

arg:class (rdfs:Class): The class that the form is attached to.

Return type

Function body

SELECT ?form
WHERE {
    {
        BIND (swa:configGraph() AS ?config) .
    } .
    GRAPH ?config {
        BIND (swa:directForm(?class) AS ?form) .
    } .
}

swa:directRelevantClassOfProperty (spin:MagicProperty)

Finds the properties that are directly attached to a given class. Note that this magic property should only be used if the class (left hand side) is given and the property (right hand side) is a variable. For the inverse operation, use swa:directRelevantPropertyOfClass.

Arguments

sp:arg1 (rdfs:Class): The class to get the properties of.

Return type

Function body

SELECT DISTINCT ?property
WHERE {
    {
        ?property rdfs:domain ?arg1 .
    }
    UNION
    {
        ?arg1 rdfs:subClassOf ?restriction .
        ?restriction owl:onProperty ?property .
    }
    UNION
    {
        {
            ?arg1 swa:directShapesForType ?shape .
            ?shape sh:property|sh:parameter ?propertyShape .
            FILTER (!dash:isDeactivated(?propertyShape)) .
        } .
        ?propertyShape sh:path ?property .
        FILTER isIRI(?property) .
    } .
    FILTER isIRI(?arg1) .
}

swa:directRelevantPropertyOfClass (spin:MagicProperty)

Finds the classes that are directly attached to a given property. In SWA this is used by the class/property tree. Note that this magic property should only be used if the property (left hand side) is given. For the inverse operation, use swa:directRelevantClassOfProperty.

Arguments

sp:arg1 (rdf:Property): The property to get the classes of.

Return type

Function body

SELECT DISTINCT ?class
WHERE {
    {
        ?arg1 rdfs:domain ?class .
    }
    UNION
    {
        ?restriction owl:onProperty ?arg1 .
        ?class rdfs:subClassOf ?restriction .
    }
    UNION
    {
        {
            ?propertyShape sh:path ?arg1 .
            ?shape sh:property|sh:parameter ?propertyShape .
            FILTER (!dash:isDeactivated(?propertyShape)) .
        } .
        ?class swa:directShapesForType ?shape .
    } .
    FILTER isIRI(?class) .
}

swa:directShapesForType (spin:MagicProperty)

Gets all sh:Shapes associated with a given type. This is not walking up the class hierarchy but collects all classes that are also instances of sh:Shape, and any shapes declared using sh:targetClass. This magic property can be used in both directions, i.e. if either the class or the shape are given.

Arguments

sp:arg1 (rdfs:Class): The type to get the property groups for.

Return type

Function body

SELECT DISTINCT ?shape
WHERE {
    {
        ?shape sh:targetClass ?arg1 .
    }
    UNION
    {
        FILTER (bound(?arg1) && spl:instanceOf(?arg1, sh:Shape)) .
        BIND (?arg1 AS ?shape) .
    }
    UNION
    {
        FILTER ((bound(?shape) && spl:instanceOf(?shape, rdfs:Class)) && spl:instanceOf(?shape, sh:Shape)) .
        BIND (?shape AS ?arg1) .
    } .
}

swa:falseOrUnbound (spin:Function)

Checks whether the provided argument is unbound or false.

Arguments

arg:value (xsd:boolean): [Optional] The input value.

Return type

Function body

ASK WHERE {
    FILTER ((!bound(?value)) || (!?value)) .
}

swa:genericTreeProperties (spin:MagicProperty)

Arguments

sp:arg1 (rdfs:Class): The resource type.

Function body

SELECT ?property ?editable
WHERE {
    {
        SELECT ?property (MIN(?editableL) AS ?editable)
        WHERE {
            {
                {
                    {
                        ?arg1 (rdfs:subClassOf)* ?type .
                        ?superProperty rdfs:domain ?type .
                        ?property (rdfs:subPropertyOf)* ?superProperty .
                        FILTER swa:filterSystemResources(?property) .
                        FILTER ((?property = ?superProperty) || NOT EXISTS {
                            ?property rdfs:domain ?ownDomain .
                        }) .
                    } .
                    BIND (swa:localRangeAtClass(?type, ?property) AS ?range) .
                } .
                FILTER EXISTS {
                    ?range (rdfs:subClassOf)* owl:Thing .
                } .
                BIND (((?range = ?type) && (!spl:instanceOf(?property, spin:MagicProperty))) AS ?editableL) .
            }
            UNION
            {
                {
                    {
                        ?arg1 (rdfs:subClassOf)* ?type .
                        ?type sh:property/sh:path ?property .
                        FILTER isIRI(?property) .
                        FILTER swa:filterSystemResources(?property) .
                    } .
                    BIND (swa:localRangeAtClass(?type, ?property) AS ?range) .
                } .
                FILTER EXISTS {
                    ?range (rdfs:subClassOf)* owl:Thing .
                } .
                BIND (((?range = ?type) && (!spl:instanceOf(?property, spin:MagicProperty))) AS ?editableL) .
            } .
        }
        GROUP BY ?property
    } .
}

swa:getClassPropertyValue (spin:Function)

Finds nearest parent class for given property

Arguments

sp:arg1 (rdfs:Resource): Current subclass
sp:arg2 (rdf:Property):

Function body

SELECT ?value
WHERE {
    ?arg1 (rdfs:subClassOf)* ?parentClass .
    ?parentClass ?arg2 ?value .
}
LIMIT 1

swa:getDefaultNamespace (spin:Function)

Picks a default namespace for new resources. This uses swa:defaultOntology to get hold of the default ontology. If this has a swa:defaultNamespace, then this will be used. Otherwise, the base URI + '/' of the default ontology is used.

Return type

Function body

SELECT ?result
WHERE {
    BIND (swa:defaultOntology() AS ?ontology) .
    BIND (spl:object(?ontology, swa:defaultNamespace) AS ?default) .
    BIND (COALESCE(?default, CONCAT(xsd:string(?ontology), "/")) AS ?result) .
}

swa:getDescription (spin:Function)

Gets the "description" for a given resource. This will try to find a suitable value for one of the sub-properties of swa:description, based on the languages requested by the user. The function is natively implemented due to the complications of comparing languages and performance. The result might be any literal including rdf:HTML where applicable.

Arguments

arg:resource (rdfs:Resource): The resource to get the image for.

Return type


swa:globalRange (spin:Function)

Gets the global range (rdfs:range) of a property. If none is provided, it will walk up super-properties.

Arguments

arg:property (rdf:Property): The property to get the range of.

Return type

Function body

SELECT ?range
WHERE {
    ?property (rdfs:subPropertyOf)* ?p .
    ?p rdfs:range ?range .
}

swa:graphIsEmpty (spin:Function)

Checks whether a given graph is empty.

Arguments

arg:graph (rdfs:Resource): The graph to test.

Return type

Function body

ASK WHERE {
    FILTER NOT EXISTS {
        GRAPH ?graph {
            ?s ?p ?o .
        } .
    } .
}

swa:graphLabel (spin:Function)

Gets the display label of a given graph, with special handling of certain system namespaces.

Arguments

arg:graph (rdfs:Resource): The graph to get the label for.

Return type

Function body

SELECT ?result
WHERE {
    {
        ?graph rdfs:label ?result .
    }
    UNION
    {
        GRAPH ui:graph {
            ?graph rdfs:label ?result .
        } .
    } .
}

swa:graphQLService (spin:Function)

Gets the URL of the GraphQL service for a given graph. Returns nothing for graphs that do not provide a GraphQL service.

Arguments

arg:graph (rdfs:Resource): The URI of the graph to get the GraphQL service for.

Return type


swa:hasAppName (spin:Function)

Checks if a given string contains a given app name.

Arguments

sp:arg1 (xsd:string): The string to check - may contain a comma-separated list of app names.
sp:arg2 (xsd:string): The name to match against, e.g. "EVN".

Return type

Function body

ASK WHERE {
    {
        FILTER (bound(?arg1) && bound(?arg2)) .
    } .
    ?sub1 spif:split ( ?arg1 "," ) .
    ?sub2 spif:split ( ?arg2 "," ) .
    FILTER (?sub1 = ?sub2) .
}

swa:hasCurrentAppName (spin:Function)

Checks if the current context is in a given application, as identified by the context variable "swaAppName".

Arguments

arg:appName (xsd:string): The name to match against, e.g. "EVN".

Return type

Function body

ASK WHERE {
    FILTER swa:hasAppName(ui:contextValue("swaAppName"), ?appName) .
}

swa:hasDirectForm (spin:Function)

Checks whether there is a direct form attached to a given class.

Arguments

arg:class (rdfs:Class): The class to check for a form.

Return type

Function body

ASK WHERE {
    GRAPH ui:graph {
        BIND (swa:directForm(?class) AS ?form) .
        FILTER bound(?form) .
    } .
}

swa:hasDirectFormOutsideConfigGraph (spin:Function)

Checks whether a given class has a direct form attached to it, outside of the swa:configGraph(). Only classes that return false here can be edited by end users.

Arguments

arg:class (rdfs:Class): The class to check.

Return type

Function body

ASK WHERE {
    GRAPH ui:graph {
        {
            {
                ?class ui:instanceView ?form .
                BIND (swa:directFormInConfigGraph(?class) AS ?configForm) .
            } .
            FILTER ((!bound(?configForm)) || (?form != ?configForm)) .
        } .
        ?form ui:id ?ids .
        ?id spif:split ( ?ids " " ) .
        FILTER (?id = "form") .
    } .
}

swa:hasPrefix (spin:Function)

Checks if the current query model defines a prefix for a given URI resource.

Arguments

arg:resource (rdfs:Resource): The resource to check for a prefix.

Return type

Function body

ASK WHERE {
    BIND (afn:namespace(?resource) AS ?namespace) .
    ?namespace spif:prefix ?prefix .
    FILTER bound(?prefix) .
}

swa:hasPrimaryKey (spin:Function)

Arguments

arg:class (rdfs:Class): The class to check for the primary key.

Return type

Function body

ASK WHERE {
    BIND (swa:primaryKeyProperty(?class) AS ?property) .
    FILTER bound(?property) .
}

swa:hasPropertyGroupValue (spin:Function)

Checks if a given focus node has a value for any property (or inverse properties) enumerated by a given sh:PropertyGroup.

Arguments

arg:focusNode (rdfs:Resource): The node to test.
arg:group (sh:PropertyGroup): The property group.

Return type

Function body

ASK WHERE {
    ?focusNode swa:shapesForNodeFiltered ?shape .
    ?shape sh:property|sh:parameter ?propertyShape .
    ?propertyShape sh:group ?group .
    ?propertyShape sh:path ?path .
    FILTER ((isIRI(?path) && EXISTS {
        ?focusNode ?path ?any .
    }) || (isBlank(?path) && EXISTS {
        ?path sh:inversePath ?inverse .
        ?any ?inverse ?focusNode .
    })) .
}

swa:inversePropertyShapePropertyAtClass (spin:Function)

Gets the "first" value of a given property (such as sh:name) from inverse property constraints from all shapes associated with a given shape or class.

Arguments

arg:predicate (rdf:Property): The constrained inverse property (value of sh:path/sh:inversePath).
arg:property (rdf:Property): The property to get, e.g. sh:order.
arg:resourceType (rdfs:Class): The class.

Function body

SELECT ?value
WHERE {
    ?resourceType swa:shapesForType ?shape .
    ?shape sh:property|sh:parameter ?propertyShape .
    ?propertyShape sh:path ?path .
    ?path sh:inversePath ?predicate .
    ?propertyShape ?property ?value .
    FILTER isBlank(?path) .
    FILTER NOT EXISTS {
        ?propertyShape sh:deactivated true .
    } .
}

swa:inversePropertyShapePropertyAtNode (spin:Function)

Gets the "first" value of a given property (such as sh:name) from all property shapes on an inverse predicate associated with a given focus node. If the focus node is unbound (e.g. in search forms), this falls back to the swa:resourceTypes.

Arguments

arg:predicate (rdf:Property): The constrained inverse property (value of sh:path/sh:inversePath).
arg:property (rdf:Property): The property to get, e.g. sh:order.
arg:resource (rdfs:Resource): [Optional] The focus node or unbound.

Function body

SELECT ?value
WHERE {
    ?resource swa:shapesForNode ?shape .
    ?shape sh:property|sh:parameter ?propertyShape .
    ?propertyShape sh:path ?path .
    ?path sh:inversePath ?predicate .
    ?propertyShape ?property ?value .
    FILTER isBlank(?path) .
    FILTER NOT EXISTS {
        ?propertyShape sh:deactivated true .
    } .
}

swa:isAbstractClass (spin:Function)

Checks whether a given class is "abstract" which means that it should not have any direct instances. The is true if the class either has dash:abstract, spin:abstract or ui:abstract set to true.

Arguments

arg:class (rdfs:Resource): The class to check.

Return type

Function body

ASK WHERE {
    ?class (dash:abstract|spin:abstract)|ui:abstract true .
}

swa:isDatatypeRange (spin:Function)

Checks whether a given resource (typically the range of a property) is a datatype. It must either be equal to rdfs:Literal or an instance of rdfs:Datatype.

Arguments

arg:range (rdfs:Resource): The range to check.

Return type

Function body

ASK WHERE {
    FILTER bound(?range) .
    FILTER ((?range = rdfs:Literal) || EXISTS {
        ?range a rdfs:Datatype .
    }) .
}

swa:isImportedResource (spin:Function)

Checks whether a given resource is "imported", which is defined to be true if the resource has at least one rdf:type triple that is read-only.

Arguments

arg:resource (rdfs:Resource): The resource to check.

Return type

Function body

ASK WHERE {
    ?resource a ?type .
    FILTER spif:isReadOnlyTriple(?resource, rdf:type, ?type) .
}

swa:isInferredProperty (spin:Function)

Checks whether a given property is being computed by inference (from SHACL triple rules) for a given subject.

Arguments

arg:predicate (rdf:Property): The property to check.
arg:subject (rdfs:Resource): The subject resource.

Return type

Function body

ASK WHERE {
    ?rule sh:predicate ?predicate .
    ?rule sh:subject sh:this .
    ?shape sh:rule ?rule .
    FILTER NOT EXISTS {
        ?rule sh:deactivated true .
    } .
    FILTER tosh:isInTargetOf(?subject, ?shape) .
}

swa:isMandatory (spin:Function)

Checks whether a given subject/predicate combination requires at least one value, according to the ontology. This checks for owl:minCardinality|owl:cardinality|owl:qualifiedCardinality restrictions and sh:minCount constraints.

Arguments

arg:property (rdf:Property): The property to check.
arg:subject (rdfs:Resource): [Optional] The subject - may be unbound to fall back to the subjectType.

Return type

Function body

ASK WHERE {
    FILTER (swa:isMandatoryInOWL(?property, ?subject) || swa:isMandatoryInSHACL(?property, ?subject)) .
}

swa:isMandatoryInSHACL (spin:Function)

Arguments

arg:property (rdf:Property): The property to check.
arg:subject (rdfs:Resource): [Optional] The subject - may be unbound to fall back to the subjectType.

Function body

ASK WHERE {
    ?subject swa:shapesForNodeFiltered ?shape .
    ?shape sh:property ?propertyShape .
    ?propertyShape sh:path ?property .
    ?propertyShape sh:minCount ?minCount .
    FILTER (?minCount > 0) .
}

swa:isMulti (spin:Function)

Checks whether a given subject/predicate combination can have multiple values, according to the ontology. This checks for owl:maxCardinality restrictions, existing spl:Argument constraints and whether the property is functional. Note that TopBraid Suite uses a native (optimized) implementation of this function, i.e. the SPIN body is never called when used inside of TopBraid Suite.

Arguments

arg:property (rdf:Property): The property to check.
arg:subject (rdfs:Resource): [Optional] The subject - may be unbound to fall back to the subjectType.

Return type

Function body

ASK WHERE {
    FILTER NOT EXISTS {
        ?property a owl:FunctionalProperty .
    } .
    BIND (swa:resourceType(?subject) AS ?class) .
    BIND (swa:owlMaxCardinality(?class, ?property) AS ?max) .
    FILTER ((!bound(?max)) || (?max > 1)) .
    BIND (swa:splArgumentOnProperty(?class, ?property) AS ?arg) .
    FILTER (!bound(?arg)) .
}

swa:isNotUsedInInversePath (spin:Function)

Can be used as filter function in swa:SubjectsGroup to suppress an "Incoming References" widget for properties already inserted via SHACL property groups.

Arguments

arg:predicate (rdf:Property): The predicate to look for.
arg:resource (rdfs:Resource): The (object) resource.

Return type

Function body

ASK WHERE {
    FILTER NOT EXISTS {
        ?resource swa:shapesForNodeFiltered ?shape .
        ?shape sh:property ?ps .
        ?ps sh:path ?inversePath .
        FILTER isBlank(?inversePath) .
        FILTER EXISTS {
            ?ps sh:group ?anyGroup .
        } .
        ?inversePath sh:inversePath ?predicate .
    } .
}

swa:isOntologyResource (spin:Function)

Checks whether a given resource is an "ontology resource", which is either a class, property or shape. This can be used to determine whether a resource should become editable on a form, depending on whether the current vocabulary is supposed to only contain individuals.

Arguments

arg:resource (rdfs:Resource): The resource to check.

Return type

Function body

ASK WHERE {
    FILTER ((spl:instanceOf(?resource, rdfs:Class) || spl:instanceOf(?resource, rdf:Property)) || spl:instanceOf(?resource, sh:Shape)) .
}

swa:isValidObjectForPredicateAtSubject (spin:Function)

Checks whether a given node would be a valid object for a given subject/predicate combination, based on SHACL constraints. This will walk through all applicable property constraints at shapes that have the subject in its target. From those, it will currently only look for sh:not shapes.

Arguments

arg:object: The object to check.
arg:predicate (rdfs:Resource): The predicate to check.
arg:subject (rdfs:Resource): The subject to check at.

Return type

Function body

ASK WHERE {
    FILTER NOT EXISTS {
        ?subject swa:shapesForNodeFiltered ?shape .
        ?shape sh:property ?propertyShape .
        ?propertyShape sh:path ?predicate .
        ?propertyShape sh:not ?not .
        FILTER tosh:hasShape(?object, ?not) .
    } .
}

swa:labelInGraph (spin:Function)

Calls ui:label in the context of a given graph.

Arguments

arg:resource (rdfs:Resource):
arg:resourceGraph (rdfs:Resource): The graph to operate on.

Return type

Function body

SELECT ?label
WHERE {
    GRAPH ?resourceGraph {
        BIND (ui:label(?resource) AS ?label) .
    } .
}

swa:letters (spin:MagicProperty)

Binds the variable on the left with all letters from A-Z.

Return type

Function body

SELECT ?letter
WHERE {
    BIND ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" AS ?str) .
    BIND (fn:string-length(?str) AS ?length) .
    ?x spif:for ( 1 ?length ) .
    BIND (fn:substring(?str, ?x, 1) AS ?letter) .
}

swa:lineBreak (spin:Function)

Produces a line break (\n) character.

Return type

Function body

SELECT ?result
WHERE {
    BIND ("\n" AS ?result) .
}

swa:listMemberType (spin:Function)

Gets the declared type of list members for a given rdf:List-valued property at a given subject. This looks for SHACL patterns, currently limited to sh:property rdf:rest*/rdf:first combined with sh:datatype or sh:class.

Arguments

arg:property (rdf:Property): The rdf:List-valued property.
arg:subject (rdfs:Resource): The subject to get the member type of.

Return type

Function body

SELECT ?result
WHERE {
    ?subject swa:shapesForNodeFiltered ?shape .
    ?shape sh:property|sh:parameter ?propertyShape .
    ?propertyShape sh:path ?property .
    ?propertyShape sh:property ?nested .
    ?nested sh:path ?sequence .
    ?sequence rdf:first ?first .
    ?first sh:zeroOrMorePath rdf:rest .
    ?sequence rdf:rest ?rest .
    ?rest rdf:first rdf:first .
    ?nested sh:datatype|sh:class ?result .
}

swa:localUnionRangeAtClass (spin:Function)

Checks if a given class has multiple "ranges" for a given property, defined via sh:or constraints at the nearest shape, and returns that sh:or if it does. Otherwise, returns nothing.

Arguments

arg:class (rdfs:Class): The class to start traversal at.
arg:property (rdf:Property): The property to get the local range of.

Return type


swa:objectsList (spin:Function)

Collects all values (objects) of a given subject/predicate combination into a single string list, separated by commas. If there is just a single literal value, then return that value in the original data type. Used by SWA search forms to display optional (key) columns.

Arguments

sp:arg1 (rdfs:Resource): The subject to get the objects of.
sp:arg2 (rdf:Property): The predicate to get the objects of.

swa:orderedObjectLabels (spin:MagicProperty)

Produces an ordered iterator over the ui:labels of the objects of a given subject/predicate combination. This is required by swa:objectsList because the GROUP_CONCAT is applied before ORDER BY (probably a Jena bug).

Arguments

sp:arg1 (rdfs:Resource): The subject to get the objects of.
sp:arg2 (rdf:Property): The predicate

Return type

Function body

SELECT ?label
WHERE {
    ?arg1 ?arg2 ?value .
    BIND (ui:label(?value) AS ?label) .
}
ORDER BY (?label)

swa:orderedSubjectLabels (spin:MagicProperty)

Produces an ordered iterator over the ui:labels of the subjects of a given object/predicate combination. This is required by swa:subjectsList because the GROUP_CONCAT is applied before ORDER BY (probably a Jena bug).

Arguments

sp:arg1 (rdfs:Resource): The object to get the subjects of.
sp:arg2 (rdf:Property): The predicate

Return type

Function body

SELECT ?label
WHERE {
    ?value ?arg2 ?arg1 .
    BIND (ui:label(?value) AS ?label) .
}
ORDER BY (?label)

swa:owlMaxCardinality (spin:Function)

Walks up the class tree to find the closest owl:maxCardinality or owl:cardinality restriction on a given property.

Arguments

arg:class (rdfs:Class): The class to get cardinality at.
arg:property (rdf:Property): The property to get the cardinality of.

Return type

Function body

SELECT ?c
WHERE {
    ?class (rdfs:subClassOf)* ?superClass .
    ?superClass owl:onProperty ?property .
    ?superClass owl:cardinality|owl:maxCardinality ?c .
}

swa:predicatesInGroup (spin:MagicProperty)

Gets all predicates that are in a given group (?arg1) at a given focus node (?arg2). If no focus node is given, it will use the context variable that is also used by swa:resourceType(). The right hand side must be a list of three unbound variables - the first will contain the predicate, the second the predicate's label and the third is a boolean that is true if the path was walked in inverse direction. This magic property is implemented natively by TopBraid for performance reasons.

Arguments

sp:arg1 (sh:PropertyGroup): The property group to get the predicate of.
sp:arg2: [Optional] The focus node or unbound.

swa:primaryKeyProperty (spin:Function)

Gets the primary key property for a given class or its superclasses - either defined using SPIN or DASH.

Arguments

arg:class (rdfs:Class): The class to get the primary key of.

Return type

Function body

SELECT ?property
WHERE {
    {
        ?class (rdfs:subClassOf)* ?type .
        ?type spin:constraint ?constraint .
        ?constraint a spl:PrimaryKeyPropertyConstraint .
        ?constraint arg:property ?property .
    }
    UNION
    {
        ?class (rdfs:subClassOf)* ?type .
        ?type sh:property ?ps .
        ?ps dash:uriStart ?uriStart .
        ?ps sh:path ?property .
        FILTER isIRI(?property) .
    } .
}

swa:primaryKeyURIStart (spin:Function)

Gets the URI start of the primary key for a given class or its superclasses - either defined using SPIN or DASH.

Arguments

arg:class (rdfs:Class): The class to get the primary key of.

Return type

Function body

SELECT ?uriStart
WHERE {
    {
        ?class (rdfs:subClassOf)* ?type .
        ?type spin:constraint ?constraint .
        ?constraint a spl:PrimaryKeyPropertyConstraint .
        ?constraint arg:uriStart ?uriStart .
    }
    UNION
    {
        ?class (rdfs:subClassOf)* ?type .
        ?type sh:property ?ps .
        ?ps dash:uriStart ?uriStart .
    } .
}

swa:propertyCommentAtNode (spin:Function)

Gets the display comment of a property in the context of a given node, falling back to swa:resourceType() if no node is provided. This is usually the rdfs:comment of the property but may be the sh:description if a suitable shape exists. This function is natively implemented for performance reasons.

Arguments

arg:property (rdf:Property): The property to get the comment of.
arg:type: The node for the context.

swa:propertyEditWidget (spin:Function)

Gets a tosh:editWidget defined for a given property at a given focus node.

Arguments

arg:focusNode: The focus node.
arg:property (rdf:Property): The predicate to get the widget for.

Function body

SELECT ?result
WHERE {
    BIND (swa:propertyShapePropertyAtNode(?property, tosh:editWidget, ?focusNode) AS ?result) .
}

swa:propertyGroupsForNode (spin:MagicProperty)

Gets all sh:PropertyGroups associated with a given node via property constraints, falling back to swa:resourceType() if no node is provided. This is walking up the class hierarchy for any shapes that are in target, then walks the property constraint and parameter declarations of these shapes to find sh:groups.

Arguments

sp:arg1 (rdfs:Resource): The resource to get the property groups for.

Return type

Function body

SELECT DISTINCT ?group
WHERE {
    {
        ?arg1 swa:shapesForNodeFiltered ?shape .
        ?shape sh:property|sh:parameter ?propertyShape .
    } .
    ?propertyShape sh:group ?group .
    FILTER (!dash:isDeactivated(?propertyShape)) .
}

swa:propertyLabelAtClassOrShape (spin:Function)

Gets the display label of a property in the context of a given class or shape. This is usually the rdfs:label of the property but may be the sh:name if a suitable shape exists. This function is natively implemented for performance reasons.

Arguments

arg:property (rdfs:Property): The property to get the label of.
arg:theClassOrShape: The class/shape for the context.

Return type


swa:propertyLabelAtNode (spin:Function)

Gets the display label of a property in the context of a given node, falling back to swa:resourceType() if no node is given. This is usually the rdfs:label of the property but may be the sh:name if a suitable shape exists. This function is natively implemented for performance reasons.

Arguments

sp:arg1 (rdf:Property): The property.
sp:arg2: The focus node, for context.

Return type


swa:propertyShapePropertyAtClass (spin:Function)

Gets the "first" value of a given property (such as sh:name) from all shapes associated with a given shape or class.

Arguments

arg:predicate (rdf:Property): The constrained property (value of sh:path).
arg:property (rdf:Property): The property to get, e.g. sh:order.
arg:resourceType (rdfs:Class): The class.

Function body

SELECT ?value
WHERE {
    ?resourceType swa:shapesForType ?shape .
    ?shape sh:property|sh:parameter ?propertyShape .
    ?propertyShape sh:path ?predicate .
    ?propertyShape ?property ?value .
}

swa:propertyShapePropertyAtClassInversePath (spin:Function)

Gets the "first" value of a given property (such as sh:name) from all shapes associated with a given shape or class, for a given inverse predicate.

Arguments

arg:predicate (rdf:Property): The constrained property (value of sh:path).
arg:property (rdf:Property): The property to get, e.g. sh:order.
arg:resourceType (rdfs:Class): The class.

Function body

SELECT ?value
WHERE {
    ?resourceType swa:shapesForType ?shape .
    ?shape sh:property|sh:parameter ?propertyShape .
    ?propertyShape sh:path ?path .
    ?path sh:inversePath ?predicate .
    ?propertyShape ?property ?value .
}

swa:propertyShapePropertyAtNode (spin:Function)

Gets the "first" value of a given property (such as sh:name) from all shapes associated with a given focus node. If the focus node is unbound (e.g. in search forms), this falls back to the swa:resourceTypes.

Arguments

arg:predicate (rdf:Property): The constrained property (value of sh:path).
arg:property (rdf:Property): The property to get, e.g. sh:order.
arg:resource (rdfs:Resource): [Optional] The focus node or unbound.

Function body

SELECT ?value
WHERE {
    ?resource swa:shapesForNode ?shape .
    ?shape sh:property|sh:parameter ?propertyShape .
    ?propertyShape sh:path ?predicate .
    ?propertyShape ?property ?value .
}

swa:propertyViewWidget (spin:Function)

Gets a tosh:viewWidget defined for a given property at a given focus node.

Arguments

arg:focusNode: The focus node.
arg:property (rdf:Property): The predicate to get the widget for.

Function body

SELECT ?result
WHERE {
    BIND (swa:propertyShapePropertyAtNode(?property, tosh:viewWidget, ?focusNode) AS ?result) .
}

swa:relevantClassOfProperty (spin:MagicProperty)

Finds the properties that are attached to a given class or its superclasses.

Arguments

sp:arg1 (rdfs:Class): The class to get the properties of.

Return type

Function body

SELECT DISTINCT ?property
WHERE {
    ?arg1 (rdfs:subClassOf)* ?cls .
    ?cls swa:directRelevantClassOfProperty ?property .
}

swa:resourceTypes (spin:MagicProperty)

Gets all rdf:types of a resource. The resource may actually not be given (e.g. when we are populating a Search form), in which case it will try to find the value of the context variable "resourceType", which is set by the surrounding form. If none of these are present, it falls back to rdfs:Resource.

Arguments

sp:arg1 (rdfs:Resource): [Optional] The resource to get the types of, or unbound to fall back to the context value.

Return type

Function body

SELECT ?result
WHERE {
    {
        {
            FILTER (bound(?arg1) && EXISTS {
                ?arg1 a ?any .
            }) .
        } .
        ?arg1 a ?result .
    }
    UNION
    {
        FILTER ((!bound(?arg1)) || NOT EXISTS {
            ?arg1 a ?any .
        }) .
        BIND (COALESCE(ui:contextValue("resourceType"), rdfs:Resource) AS ?result) .
    } .
}

swa:shapesForNode (spin:MagicProperty)

Gets all sh:Shapes associated with a given (focus) node. This is looking at the swa:resourceTypes of the node and then walks up the class hierarchy and collects all classes that are also instances of sh:Shape, and any shapes declared using sh:targetClass. Future versions will also be looking for sh:targetObjectsOf triples.

Arguments

sp:arg1 (rdfs:Resource): The focus node.

Return type

Function body

SELECT DISTINCT ?shape
WHERE {
    ?arg1 swa:resourceTypes ?type .
    ?type swa:shapesForType ?shape .
}

swa:shapesForNodeFiltered (spin:MagicProperty)

Same as swa:shapesForNode but only returning the non-deactivated shapes.

Arguments

sp:arg1 (rdfs:Resource): The focus node.

Return type

Function body

SELECT DISTINCT ?shape
WHERE {
    ?arg1 swa:shapesForNode ?shape .
    FILTER (!dash:isDeactivated(?shape)) .
}

swa:shapesForType (spin:MagicProperty)

Gets all sh:Shapes associated with a given type. This is walking up the class hierarchy and collects all classes that are also instances of sh:Shape, and any shapes declared using sh:targetClass. In TopBraid, this magic property is implemented as a native Java function for performance reasons.

Arguments

sp:arg1 (rdfs:Class): The type to get the shapes for.

Return type

Function body

SELECT DISTINCT ?shape
WHERE {
    ?arg1 (rdfs:subClassOf)* ?type .
    {
        ?shape sh:targetClass ?type .
    }
    UNION
    {
        FILTER spl:instanceOf(?type, sh:Shape) .
        BIND (?type AS ?shape) .
    } .
}

swa:shortestPathsBetweenNodes (spin:MagicProperty)

Attempts to find one or more shortests paths between two given RDF nodes in the current query graph. A path is a chain of triples, walked in either direction from a start node to an end node. It is strongly advised that the algorithm is limited by path length to prevent potential complete graph traversals. Syntax: ( ?start ?end ?maxCount ?maxLength [?pred1 ?pred2...] ) swa:shortestPathsBetweenNodes ( ?value ?predicate ?inverse ?stepIndex ?pathIndex ) Input values (left hand side): ?start - the start node (must be bound) ?end - the end node (must be bound) ?maxCount - the maximum number of paths to return (optional, defaults to 1) ?maxLength - the maximum length/depth of traversal (optional, defaults to 5) ?predX - the predicates to use, or none for any predicate Output values (all unbound variables on the right hand side, each result row represents one step in a path): ?value - the value node that was reached from the previous node ?predicate - the predicate that was used to reach ?value from the previous node ?inverse - true if ?predicate was walked from object to subject, false for subject to object (optional) ?stepIndex - the index of the step within its path (optional, starting at 0) ?pathIndex - the index of the path for cases where multiple paths are returned (optional, starting at 0)

Arguments

sp:arg1: The start node (must be concrete).
sp:arg2: The end node (must be concrete).
sp:arg3 (xsd:integer): [Optional] The maximum number of results to return. Defaults to 1.
sp:arg4 (xsd:integer): [Optional] The maximum length/depth of traversal, defaults to 5.

swa:singleParameter (spin:Function)

Gets the predicate of the parameter if a constraint component has exactly one parameter.

Arguments

arg:component (rdfs:Resource): The constraint component.

Return type

Function body

SELECT ?predicate
WHERE {
    ?component sh:parameter/sh:path ?predicate .
    FILTER (isIRI(?predicate) && NOT EXISTS {
        ?component sh:parameter/sh:path ?other .
        FILTER (?other != ?predicate) .
    }) .
}

swa:subjectsList (spin:Function)

Collects all subjects of a given object/predicate combination into a single string list, separated by commas. Used by SWA search forms to display optional (key) columns.

Arguments

sp:arg1 (rdfs:Resource): The object to get the subjects of.
sp:arg2 (rdf:Property): The predicate to get the objects of.

Return type

Function body

SELECT (GROUP_CONCAT(?label; SEPARATOR=', ') AS ?result)
WHERE {
    ( ?arg1 ?arg2 ) swa:orderedSubjectLabels ?label .
}
ORDER BY (?label)

swa:typesWithoutSuperclasses (spin:MagicProperty)

For a given resource (left hand side), this returns all direct rdf:types (right hand side), dropping any types that are superclasses of these direct types. For example, if a property has rdf:types owl:AnnotationProperty and rdf:Property, then the rdf:Property triple will not be returned because rdf:Property is a super-property of owl:AnnotationProperty.

Arguments

sp:arg1 (rdfs:Resource): The subject resource.

Function body

SELECT ?type
WHERE {
    ?arg1 a ?type .
    FILTER NOT EXISTS {
        ?arg1 a ?otherType .
        FILTER (?type != ?otherType) .
        ?otherType (rdfs:subClassOf)+ ?type .
    } .
}

swa:uiObject (spin:Function)

Similar to spl:object, but executed within the ui:graph.

Arguments

sp:arg1 (rdfs:Resource): The subject.
sp:arg2 (rdf:Property): The predicate.

Function body

SELECT ?object
WHERE {
    GRAPH ui:graph {
        BIND (spl:object(?arg1, ?arg2) AS ?object) .
    } .
}

swa:unusedURIPreCondition (spin:Function)

Can be used in conjunction with ui:preCondition to check whether a given URI has already been used in the current query graph.

Arguments

arg:resource (rdfs:Resource): The resource to check.

Return type

Function body

SELECT ?message
WHERE {
    FILTER (EXISTS {
        ?resource ?p ?o .
    } || EXISTS {
        ?s ?p ?resource .
    }) .
    BIND (fn:concat("The URI ", xsd:string(?resource), " is already used.") AS ?message) .
}

swa:validURIPreCondition (spin:Function)

Can be used with ui:preCondition to check whether a given string is a valid URI.

Arguments

sp:arg1 (xsd:string): The argument string.

Return type

Function body

SELECT ?result
WHERE {
    FILTER (!spif:isValidURI(?arg1)) .
    BIND (fn:concat("Not a well-formed absolute URI: ", ?arg1) AS ?result) .
}

ui:arg (spin:MagicProperty)

Makes it possible to query for the arguments of the current UISPIN element of a user-defined class. The argument on the left side must be an rdf:Property or a variable. The right side must be an unbound variable, that will contain the value of the argument at the current context node.

Return type


ui:baseGraph (spin:Function)

Gets the URI of the base graph of a graph previously created with ui:unionOfGraphs.

Arguments

arg:unionGraph (rdfs:Resource): The union graph to get the base graph of.

Return type


ui:canParse (spin:Function)

Checks whether a given literal can be parsed using ui:parse. Returns false if the given literal cannot be parsed as HTML (default) or XML (if second argument is true).

Arguments

arg:node: The RDF node to test. Must be a literal that can be parsed as HTML or XML.
arg:xml (xsd:boolean): [Optional] True to do the parsing in XML only, while the default is to do permissive HTML parsing.

Return type


ui:classViewElement (spin:Function)

Gets the SWP element that will be used by a ui:classView element for a given class and optional matchIds. The result is the SWP node (often a blank node) or unbound. More information about that SWP node can be queried in the ui:graph.

Arguments

arg:class (rdfs:Class): The class to get the view element of.
arg:matchIds (xsd:string): [Optional] Optional match IDs.

Return type


ui:concat (spin:Function)

Creates a string by concatenating the string representation of its arguments from left to right. This is basically identical to the SPARQL built-in CONCAT, with the important difference that unbound variables will be ignored without failure. The function is also used by the SWP parser if a user enters mixed attribute values such as arg="Hello, {= ?name }" which is mapped to ui:concat('Hello, ', ?name).

Return type


ui:contextValue (spin:Function)

Gets the value of a given context variable that was set before using ui:setContext. For example, <ui:setContext ui:varName="test" ui:value="Hello">...</ui:setContext> makes the name-value-pair test="Hello" visible for all children of the setContext element.

Arguments

sp:arg1 (xsd:string): The name of the variable to get.

ui:convertHTMLToText (spin:Function)

Take a literal containing HTML mark-up and removes any HTML elements (tags), while preserving some of the formatting using regular text. Note that by default this function returns the input node unless the datatype of the literal is rdf:HTML or the second argument is set to true.

Arguments

arg:html (rdfs:Literal): The HTML text to convert.
arg:treatAnyLiteral (xsd:boolean): [Optional] True to convert any literal. By default (or false), only literals that have datatype rdf:HTML will be converted.

Return type


ui:createSessionGraph (spin:Function)

Creates a (temporary) graph that can be accessed across multiple server call-backs, as long as a client session is active. The new graph is initially empty but can be populated using ui:update. Optionally, you can specify a base graph that will be a sub-graph of the new graph. The life cycle of a session graph ends if ui:deleteSessionGraph is called or a time out happens (after idle time).

Arguments

arg:baseGraph (rdfs:Resource): [Optional] An optional graph that should be included as subgraph into the session graph.

Return type


ui:currentQueryGraph (spin:Function)

Gets the URI resource of the currently active query graph.

Return type


ui:decodeNode (spin:Function)

Creates an RDF node from a string representation created with ui:encodeNode. This basically turns a qname back into a URI etc.

Arguments

sp:arg1 (xsd:string): The id of the RDF node to decode.

ui:deleteSessionGraph (spin:Function)

Deletes a session graph that was previously created using ui:createSessionGraph. The function has side effects to the state of the SWP engine, but returns a dummy boolean (true) if the operation is succesful.

Arguments

arg:sessionGraph (rdfs:Resource): The graph to delete.

Return type


ui:encodeContext (spin:Function)

Creates a URL-encoded string consisting of name-value pairs based on the current SWP context variable bindings, that the SWP servlet can use to initialize context variables for its current request. This can be used to hand-code context-sensitive Ajax loading similar to how ui:loadable does it. In a typical scenario, the result of this function would be stored as a "hidden" attribute in the DOM tree, and then added to the request URL (parameters) when needed.

Return type


ui:encodeNode (spin:Function)

Creates a string representation of a given RDF node (?arg1). By default this is using qnames where possible, unless the optional third argument is set to true.

Arguments

sp:arg1: The node to encode.
sp:arg2 (xsd:boolean): [Optional] True to have round-trippable blank nodes. Will encode them as <@ID>.
sp:arg3 (xsd:boolean): [Optional] true to not use qnames for URI nodes.

Return type


ui:encodeURL (spin:Function)

Encodes a given string so that it can be made part of a well-formed URL, e.g. in server callbacks.

Arguments

sp:arg1: The string or URI resource to encode.

Return type


ui:escapeJSON (spin:Function)

Converts a given string to a JSON-friendly string that can be sent across the wire. In particular, this replaces " with \" so that string literals can be put between matching " braces.

Arguments

sp:arg1 (xsd:string): The string to escape.

Return type


ui:functionCall (spin:Function)

Creates the source code of a JavaScript function call. The first argument is the function name, all others are rendered into comma-separated arguments. The function takes care of correct escaping. URI resources are turned into strings of their URI.

Arguments

sp:arg1 (xsd:string): The function name without the round brackets, e.g. "$('#input').val".

Return type

Examples

ui:functionCall("test", "Hello \"", 42, false, owl:Thing)
Result:  test("Hello \"", 42, false, "http:\/\/www.w3.org\/2002\/07\/owl#Thing")

ui:getSessionAttribute (spin:Function)

Gets an attribute of the currently active client session.

Arguments

sp:arg1 (xsd:string): The name of the attribute to get.

Return type


ui:globalVarValue (spin:Function)

Gets the value of a global variable.

Arguments

ui:name (xsd:string): The name of the variable to get.

Function body

SELECT ?object
WHERE {
    GRAPH ui:tempGraphGlobalVars {
        BIND (ui:GlobalVars AS ?subject) .
        BIND (IRI(CONCAT("urn:x-global-var:", ?name)) AS ?predicate) .
        BIND (spl:object(?subject, ?predicate) AS ?object) .
    } .
}

ui:graphWithImports (spin:Function)

Casts a given named graph resource to an encoded resource that instructs the engine to also include the owl:imports closure (and the system graph). Details of how to encode such resources are left to the engine but need to be consistent with the sibling function ui:graphWithoutImports. Returns the original graph unchanged if it already has the additional encoding.

Arguments

sp:arg1 (rdfs:Resource): The graph resource to cast.

Return type


ui:graphWithoutImports (spin:Function)

Opposite of ui:graphWithImports.

Arguments

sp:arg1 (rdfs:Resource): The graph resource to cast.

Return type


ui:jsonArrayMembers (spin:MagicProperty)

Iterates over a given "native" JSON array (left hand side) producing bindings for the variable on the right hand side.

Arguments

sp:arg1: The JSON array.

ui:jsonKeys (spin:MagicProperty)

Binds the keys of a JSON object on the left hand side to the variable on the right.

Arguments

sp:arg1: The JSON object.

Return type


ui:jsonString (spin:Function)

Turns a "native" JSON value into an RDF string literal.

Arguments

arg:jsonValue: The JSON value node.

Return type


ui:jsonValue (spin:Function)

Gets the value of a "native" JSON object, as another "native" JSON value.

Arguments

arg:jsonObject: The "native" JSON object to get the value of.
arg:key (xsd:string): The key of the JSON value to get at the JSON object.

ui:label (spin:Function)

Computes the display label for a given RDF node (literal or resource). For resources, this typically uses the rdfs:label (or sub-property thereof). However, this behavior can be customized with a global setting to redirect ui:label to a different string-producing function. Deeper sub-properties are preferred over their super-properties. For some literal types such as xsd:date and xsd:float, this uses localization settings based on ui:lang(), e.g. "4.2"^^xsd:float is rendered as 4,2 when the current language is "de". For all other literal datatypes, the plain lexical form of the literal is put out.

Arguments

sp:arg1: The node to get the label of.
sp:arg2 (xsd:string): [Optional] An optional style that is used by the date/time literal types. Currently supported values are: "short", "medium", "long" and "full".

Return type


ui:lang (rdf:Property)

Gets the language that shall be used in the current request. The language is in the same format as the RDF language tags. It is usually specified by the system as part of the incoming client request. It is also possible to explicitly set the language for child element using ui:setContext.

Return type


ui:lib (spin:Function)

Creates the start of the "lib" servlet that is used to access static files within the SWP servlet. Instead of hard-coding this (e.g. "lib/assets/js/swa.js") you should always use this function to resolve the first segment, e.g. "{= ui:lib() }/assets/js/swa.js". This allows the engine to inject additional info such as the version number into the path.

Return type

Function body

SELECT ?result
WHERE {
    BIND ("lib" AS ?result) .
}

ui:nearestViewWithType (spin:Function)

Walks up the hierarchy of parent views starting with the current view, and finds the first parent that has a given rdf:type.

Arguments

arg:type (rdfs:Resource): The type of the parent.

Return type


ui:param (spin:Function)

Gets the value of a parameter passed in as part of the current HTTP request. Optionally, the parameter can be cast into a given type. The returned value is escaped in SPARQL syntax.

Arguments

arg:name (xsd:string): The name of the parameter.
arg:type (rdfs:Class): [Optional] The type to cast the string to (defaults to xsd:string).

ui:params (spin:MagicProperty)

Gets the names of all parameters to the current servlet request. See ui:param to access the actual value of each parameter. Usage: SELECT ?key ?value WHERE { () ui:params ?key . BIND (ui:param(?key) AS ?value) . }

Return type


ui:progressMonitorStatus (spin:MagicProperty)

A property function that returns the current status of a long-running process, as reported by the process in the <ui:task> and <ui:subTask> control elements. Synax: ?progressId ui:progressMonitorStatus ( ?task ?subTask ?totalWork ?completedWork ) . The subject must be a concrete URI or literal, or a variable bound to one. All members of the object list must be unbound variables. ?progressId - the identifier of the long-running process, e.g., the _progressId argument passed to the SWP servlet ?task - a label for the long-running task ?subTask - a label for the currently executing sub-task ?totalWork - an integer indicating the total number of work units in the task ?completedWork - an integer indicating the number of completed work units


ui:resourceViewElement (spin:Function)

Gets the SWP element that will be used by a ui:resourceView element for a given resource and optional matchIds. The result is the SWP node (often a blank node) or unbound. More information about that SWP node can be queried in the ui:graph.

Arguments

arg:matchIds (xsd:string): [Optional] Optional match IDs.
arg:resource (rdfs:Resource): The resource to get the view element of.

Return type


ui:server (spin:Function)

Gets the server as returned by the currently running SWP engine.

Return type


ui:setSessionAttribute (spin:Function)

Sets an attribute of the currently active client session. This makes it possible to maintain state while the user is clicking between multiple SWP pages in the browser. The result of the function itself is the empty string.

Arguments

sp:arg1 (xsd:string): The name of the attribute to set.
sp:arg2 (xsd:string): The new value of the attribute.

Return type


ui:systemPreference (spin:Function)

Gets a system preference set by the UISPIN execution environment. These are typically server-specific settings such as how to redirect hyperlinks, or Google API keys, that can be queried by UISPIN elements to adjust the page generation.

Arguments

sp:arg1 (xsd:string): The name of the preference to get.

Return type


ui:unionOfGraphs (spin:Function)

Takes one or more URI resources of named graphs and produces a new URI resource describing a graph that will be recognized by the engine as the union of the named graphs. This can be used to construct temporary query graphs and pass them around with a well-defined URI. All arguments must be URI resources - there can be any number of them. Use ui:baseGraph() for the "reverse" of this operation.

Return type


ui:unionOfGraphsFromResultSet (spin:Function)

Takes a result set listing a collection of graph nodes (URI resources) and produces a new URI resource describing a graph that will be recognized by the engine as the union of those named graphs. This can be used to construct temporary query graphs and pass them around with a well-defined URI. This function can only be used inside of an executing SWP engine, because it needs to access the result set object. Use ui:baseGraph() for the "reverse" of this operation.

Arguments

arg:resultSet (spr:Table): The SPR result set to walk through.

Return type


ui:uniqueId (spin:Function)

Generates a string identifier that is unique for the life time of the UISPIN execution engine.

Return type


xsd:boolean (spin:Function)

As a SPARQL function, this converts a given node (?arg1) to an xsd:boolean literal.

Arguments

sp:arg1: The input value.

Return type


xsd:date (spin:Function)

As a SPARQL function, this converts a given node (?arg1) to an xsd:date literal.

Arguments

sp:arg1: The input value.

Return type


xsd:dateTime (spin:Function)

As a SPARQL function, this converts a given node (?arg1) to an xsd:dateTime literal.

Arguments

sp:arg1: The input value.

Return type


xsd:decimal (swa:NumericDatatype)

Arguments

sp:arg1: The input value.

Return type


xsd:float (swa:NumericDatatype)

As a SPARQL function, this converts a given node (?arg1) to an xsd:float literal.

Arguments

sp:arg1: The input value.

Return type


xsd:integer (swa:NumericDatatype)

As a SPARQL function, this converts a given node (?arg1) to an xsd:integer literal.

Arguments

sp:arg1: The input value.

Return type


xsd:string (spin:Function)

As a SPARQL function, this converts a given node (?arg1) to an xsd:string literal. If the input is a resource, then the URI of that resource will be returned.

Arguments

sp:arg1: The input node.

Return type


xsd:time (spin:Function)

As a SPARQL function, this converts a given node (?arg1) to an xsd:time literal.

Arguments

sp:arg1: The input value.

Return type