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) {
        return null;
     }
     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]> 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].
> 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].
> 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] <[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
<https://paper.li/TilFrozza/1460718203>*
*STARTUP NEWS - http://paper.li/TilFrozza/1392231760
<http://paper.li/TilFrozza/1392231760>*
*A CAVERNA DO MESTRE - http://paper.li/TilFrozza/1392230815
<http://paper.li/TilFrozza/1392230815>*
*RESUMO DA SEMANA - http://paper.li/TilFrozza/1392231274
<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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/CANAF59JJm4ijuNVJrdOacE4XAj5ODZR%2B%2BkFH7VpYEgpbQC8xcw%40mail.gmail.com.

Attachment: Case_1-DataGraph.ttl
Description: Binary data

Attachment: Case_1-ShapeGraph.ttl
Description: Binary data

function myMinOccur ($this, $minSize) {
	// Defines an array for the return
	var results = [];
	// Defines the target node's IRI
	var propertyName = TermFactory.namedNode("http://www.example.org/ns#coordinates";);  
    // Finds the object defined by the target node
	var propertyObject = $data.find($this, propertyName, null) ;
	// Navigate the target node graph
    for (var t = propertyObject.next(); t; t = propertyObject.next()) {
		var coordTriple = propertyObject.next();
		if (!coordTriple) {
			return $this.value ;//null;
		}
		// Each instance is a Javascript object
		var coordinate = coordTriple.object;
		// We are interested in array objects,
		// with array lenght < $minSize
		if (coordinates.length < $minSize ) {
			results.push({
				value : coordinates
			});
		}
	}
	return results;
}

Reply via email to