You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2023/02/19 09:29:22 UTC
[jena-site] 01/01: Update javascript-functions for setup documentation
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch script-setting
in repository https://gitbox.apache.org/repos/asf/jena-site.git
commit 65a40504d161bb0d588b846c6b33b42539be9094
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Sun Feb 19 09:28:48 2023 +0000
Update javascript-functions for setup documentation
---
source/documentation/query/javascript-functions.md | 27 +++++++++++++---------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/source/documentation/query/javascript-functions.md b/source/documentation/query/javascript-functions.md
index 9d079d45c..1d95a3702 100644
--- a/source/documentation/query/javascript-functions.md
+++ b/source/documentation/query/javascript-functions.md
@@ -35,21 +35,30 @@ be added to the classpath.
<version>${ver.graalvm}/version>
</dependency>
```
-
-## Loading JavaScript functions
+
+## Enabling and Loading JavaScript functions
JavaScript is loaded from an external file using the context setting
"http://jena.apache.org/ARQ#js-library". This can be written as
`arq:js-library` for commands and Fuseki configuration files.
+Access to the script engine must be enabled at runtime.
+The Java system property to do this is `jena:scripting`.
+
Example:
+ export JVM_ARGS=-Djena:scripting=true
+ sparql --set arq:js-library=SomeFile.js --data ... --query ...
+
+and for MS Windows:
+
+ set JVM_ARGS=-Djena:scripting=true
sparql --set arq:js-library=SomeFile.js --data ... --query ...
will execute on the data with the JavaScript functions from file
"SomeFile.js" available.
-JavScript functions can also be set from a string directly from within Java using constant
+JavaScript functions can also be set from a string directly from within Java using constant
`ARQ.symJavaScriptFunctions` ("http://jena.apache.org/ARQ#js-functions").
## Using JavaScript functions
@@ -97,9 +106,7 @@ For example, "some words to process " becomes "someWordsToProcess".
// Words to be combined are separated by a space in the string.
function toCamelCase(str) {
- return str.split(' ')
- .map(cc)
- .join('');
+ return str.split(' ').map(cc).join('');
}
function ucFirst(word) {
@@ -123,11 +130,7 @@ and the query `Q.rq`
VALUES ?input { "some woRDs to PROCESS" }
}
-which can be executed with:
-
- sparql --set arq:js-library=functions.js --query Q.rq
-
-and it results in:
+which results in:
--------------------------------------------------
| input | X |
@@ -140,6 +143,7 @@ and it results in:
The context setting can be provided on the command line starting the
server, for example:
+ export JVM_ARGS=-Djena:scripting=true
fuseki --set arq:js-library=functions.js --mem /ds
or it can be specified in the server configuration file `config.ttl`:
@@ -171,4 +175,5 @@ or it can be specified in the server configuration file `config.ttl`:
and used as:
+ export JVM_ARGS=-Djena:scripting=true
fuseki --conf config.ttl