The syntax supported in the JS Query view is based on this library
https://github.com/TopQuadrant/shacl-js/blob/master/shared/rdfquery.js
which provides syntactic sugar to more efficiently walk through RDF results.
So instead of doing a "for" loop you can use match as in
var result = $data.query().
match("owl:Class", "rdfs:label", "?label").
match("?otherClass", "rdfs:label", "?label").
filter(function(sol) { return
!T("owl:Class").equals(sol.otherClass) }).
getNode("?otherClass");
This library is also used for the implementation of most built-in
constraints in TopBraid's SHACL-JS implementation, see
https://github.com/TopQuadrant/shacl-js/blob/master/shared/dash.js
Not sure if this helps or distracts in your SHACL-JS exercises, so I
just wanted to point it out.
Holger
On 22/02/2020 05:49, Angelo Frozza wrote:
Hi Holger,
Are there any tutorials for using the Javascript query in TBC?
I couldn't understand how to start my test script on that interface.
In my case study, I need to:
- read the instances of ex: coordinates (a list of geographical
coordinates)
- Browse the list and, for each member of the list, do:
a) check if it is of the data type xsd:decimal
b) accumulate 1 in the element counter
a) is a restriction of the members of the list
b) it is an instance constraint and must be compared against
ex:minOccur in my shape (e.g.: it must have at least 2 geographic
coordinates).
An attempt to start the code was:
|
propertyName
=TermFactory.namedNode("http://www.example.org/ns#coordinates");
propertyObject = $data.find($this, propertyName,null);
for(t = propertyObject.next(); t; t = propertyObject.next()){
coordTriple = propertyObject.next();
if(!coordTriple){
returnnull;
}
coordinate = coordTriple.object;
if(coordinates.length < $minSize ){
results.push({
value : coordinates
});
}
}
|
But the Javascript query is not accepting that way (I think it's syntax).
Hugs,
Angelo
Em qua., 19 de fev. de 2020 às 22:35, Holger Knublauch
<[email protected] <mailto:[email protected]>> escreveu:
Hi Angelo,
using TBC-FE (Free Edition), SHACL-JS does work. I have tested
your previous file, fixing the www. in the label of one instance
and get this:
I agree debugging JS can be difficult from a Java-based tool that
goes into the JS Nashorn engine. One way to debug things is to run
the JS queries separately. The JavaScript Query view in TBC-FE
could be used potentially:
Basically you could write your JS code there and put them into the
.js file when you are confident they work.
Other than this, feel free to send a minimal and complete example
of where you are stuck, here or on the shacl w3c mailing list.
Holger
On 20/02/2020 04:29, Angelo Frozza wrote:
Hello,
I am developing a case study and I have 3 files:
- DataGraph.ttl - data graph
- ShapeGraph.ttl - shape graph with SHACL-JS
- Functions.js - functions for SHACL-JS
I'm using the SHACL API by command line, but I'm having trouble
debugging the shapefile and the JavaScript function (I don't know
what's being passed to the variables).
Apparently, the function is being accessed, however, it does not
find the object to which the validation is applied (ex:coordinates).
Using TBCFE I tried to import the shapegraph and datagraph files
for a new project (the functions.js file is accessed online), but
I was unable to validate the data graph through the Model ->
Refresh and show problems (constraints) menu.
Can TBCFE be used with SHAC-JS?
If yes, can someone help me with a step by step?
I believe that I may have several errors in the shapefile or in
the Javascript function. My biggest difficulty is in debugging
these codes.
Best regards,
Angelo
--
You received this message because you are subscribed to the
Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/33b1fe62-6984-4725-8183-1fc7efe2906d%40googlegroups.com
<https://groups.google.com/d/msgid/topbraid-users/33b1fe62-6984-4725-8183-1fc7efe2906d%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google
Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/6d7682b3-1b84-3a5a-0af3-b962fa84c1a9%40topquadrant.com
<https://groups.google.com/d/msgid/topbraid-users/6d7682b3-1b84-3a5a-0af3-b962fa84c1a9%40topquadrant.com?utm_medium=email&utm_source=footer>.
--
-----
Prof. Angelo Augusto Frozza, M.Sc.
[email protected] <mailto:[email protected]>
Doutorando PPGCC/UFSC
Professor EBTT
IFC - Instituto Federal Catarinense - Campus Camboriú
http://about.me/tilfrozza
*_Sugestões de leitura:_*
*_NoSQL DAiLY - https://paper.li/TilFrozza/1460718203_*
*_STARTUP NEWS - http://paper.li/TilFrozza/1392231760_*
*_A CAVERNA DO MESTRE - http://paper.li/TilFrozza/1392230815_*
*_RESUMO DA SEMANA - http://paper.li/TilFrozza/1392231274_*
--
You received this message because you are subscribed to the Google
Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/CANAF59JJm4ijuNVJrdOacE4XAj5ODZR%2B%2BkFH7VpYEgpbQC8xcw%40mail.gmail.com
<https://groups.google.com/d/msgid/topbraid-users/CANAF59JJm4ijuNVJrdOacE4XAj5ODZR%2B%2BkFH7VpYEgpbQC8xcw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "TopBraid
Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/03551738-7f6b-bbe0-8e3c-a03380f818c1%40topquadrant.com.