[topbraid-users] extending SM Module

2016-06-07 Thread german . peter81
Hi,

I would like to to specialize existing SM module, by binding some of its 
arguments. More concretely, i would like to create module 
my:ImportGoogleSpreadsheetCSV by extending module sml:ImportFileFromURL. 
my:ImportGoogleSpreadsheetCSV should have 2 additional parameters -- 
documentId and sheetId. This is my definition of the module :

my:ImportGoogleSpreadsheetCSV
  rdf:type sm:Module ;
  spin:constraint [
  rdf:type spl:Argument ;
  spl:predicate sml:documentId ;
  spl:valueType xsd:string ;
  rdfs:comment "Document Id."^^xsd:string ;
] ;
  spin:constraint [
  rdf:type spl:Argument ;
  spl:predicate sml:sheetId ;
  spl:valueType xsd:string ;
  rdfs:comment "Spreadsheet id."^^xsd:string ;
] ;
  spin:constructor [
  rdf:type sp:Construct ;
  sp:templates (
  [
sp:object [
sp:varName "url"^^xsd:string ;
  ] ;
sp:predicate sml:url ;
sp:subject spin:_this ;
  ]
) ;
  sp:text """CONSTRUCT {
   ?this sml:url ?url .
}
WHERE {
   BIND(CONCAT(\"https://docs.google.com/spreadsheets/d/\";, ?documentId, 
\"/export?format=csv&gid=\", ?sheetId) as ?url)
}"""^^xsd:string ;
  sp:where (
  [
rdf:type sp:Bind ;
sp:expression [
rdf:type sp:concat ;
sp:arg1 "https://docs.google.com/spreadsheets/d/"; ;
sp:arg2 [
sp:varName "documentId"^^xsd:string ;
  ] ;
sp:arg3 "/export?format=csv&gid=" ;
sp:arg4 [
sp:varName "sheetId"^^xsd:string ;
  ] ;
  ] ;
sp:variable [
sp:varName "url"^^xsd:string ;
  ] ;
  ]
) ;
] ;
  rdfs:label "Import CSV from Google Spreadsheet"^^xsd:string ;
  rdfs:subClassOf sml:ImportFileFromURL ;
.


Idea is to use CONCAT function to bind ?url in spin:constructor. However, 
 It gives me error: "Operation failed: 
org.topbraid.spin.sparqlmotion.modules.SMException: the string value is 
missing for url". This is clearly because sml:ImportFileFromURL module has 
"sml:url" argument which is required.

It there any way to disable required argument ? Is it correct way to do it 
? Are there any other options to do it ?

Cheers,
Peter


-- 
You received this message because you are subscribed to the Google Group 
"TopBraid Suite Users", the topics of which include the TopBraid Suite family 
of products and its base technologies such as SPARQLMotion, SPARQL Web Pages 
and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[topbraid-users] general constraint checking 'library'?

2016-06-07 Thread Jack Hodges
Topbraid Composer has several SPIN functions that are pretty specific to 
defining constraints for model testing. Examples are spl:instanceOf, 
spl:hasValueOfType, smf:definedIn, smf:min/maxCardinality, smf:qname, 
spif:localName, spin:constructViolations, spin:violatesConstraints, etc. It 
seems clear that some effort has been expended to create functions that 
could be used in a generic constraints 'library' (i.e., to validate type, 
cardinality, value, threshold, range, ...), but does such a library of SPIN 
functions and ASK templates already exist? I hate to reinvent the wheel...

Jack

-- 
You received this message because you are subscribed to the Google Group 
"TopBraid Suite Users", the topics of which include the TopBraid Suite family 
of products and its base technologies such as SPARQLMotion, SPARQL Web Pages 
and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [topbraid-users] Support for square root

2016-06-07 Thread Holger Knublauch

Hi Steve,

Jena already includes a number of math functions including 
afn:sqrt(num), see


http://jena.apache.org/documentation/query/library-function.html

These functions are not however listed in the afn namespace as instances 
of spin:Function and therefore do not show up in auto-complete etc.


Andy also updated me that Jena 3 (with TopBraid 5.2) will include the 
math functions from


https://www.w3.org/TR/xpath-functions-31/

Thanks
Holger



On 7/06/2016 4:40, Steve Ray (CMU) wrote:


Seeing the release of TopBraid 5.1.4 reminded me that I would like to 
suggest the addition of the square root function to your standard 
library of math functions. I know others have bumped into this omission.


In the meantime, I went ahead and defined it with the following code:

rules:sqrt

rdf:type spin:Function ;

spin:constraint [

rdf:type spl:Argument ;

spl:predicate sp:arg1 ;

] ;

spin:returnType xsd:float ;

spinx:javaScriptCode "return Math.sqrt (arg1)"^^xsd:string ;

rdfs:comment "Compute the square root of a number."^^xsd:string ;

rdfs:subClassOf spin:Functions ;

…which requires importing http://spinrdf.org/spinx (from 
/TopBraid/SPIN/spinx.ttl)


I know it’s easy for users to just do this, but many people may not 
want to figure out how to bring in javascript snippets and locate the 
Math library.


Of course, you would use a different prefix than “rules” which I did.

- Steve

Steven R. Ray, Ph.D.

Distinguished Research Fellow

Carnegie Mellon University

NASA Research Park

Building 23 (MS 23-11)

P.O. Box 1
Moffett Field, CA 94305-0001

Email: steve@sv.cmu.edu

Phone: (650) 587-3780

Cell: (202) 316-6481

Skype: steverayconsulting

cid:A9ED74CE-68DA-4276-847C-3C08B21B97C0@wv.cc.cmu.edu

--
You received this message because you are subscribed to the Google 
Group "TopBraid Suite Users", the topics of which include the TopBraid 
Suite family of products and its base technologies such as 
SPARQLMotion, SPARQL Web Pages and SPIN.

To post to this group, send email to topbraid-users@googlegroups.com
---
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 topbraid-users+unsubscr...@googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Group "TopBraid 
Suite Users", the topics of which include the TopBraid Suite family of products and 
its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [topbraid-users] Support for square root

2016-06-07 Thread Steve Ray
Thanks, Holger,

That’s good to know.

Generally, when I’m looking for functions to use, I refer to the “TopBraid 
SPARQL Functions reference” section in TBC Help.

Updating that with either the new afn: functions, or a link to 
http://jena.apache.org/documentation/query/library-function.html in the help 
file would be a good way for users to know what is available.

 

 

- Steve

 

Steven R. Ray, Ph.D.

Distinguished Research Fellow

Carnegie Mellon University

NASA Research Park

Building 23 (MS 23-11)

P.O. Box 1
Moffett Field, CA 94305-0001

Email:steve@sv.cmu.edu

Phone: (650) 587-3780

Cell:  (202) 316-6481

Skype: steverayconsulting

cid:A9ED74CE-68DA-4276-847C-3C08B21B97C0@wv.cc.cmu.edu

 

From: topbraid-users@googlegroups.com [mailto:topbraid-users@googlegroups.com] 
On Behalf Of Holger Knublauch
Sent: Tuesday, June 07, 2016 3:52 PM
To: topbraid-users@googlegroups.com
Subject: Re: [topbraid-users] Support for square root

 

Hi Steve,

Jena already includes a number of math functions including afn:sqrt(num), see

http://jena.apache.org/documentation/query/library-function.html

These functions are not however listed in the afn namespace as instances of 
spin:Function and therefore do not show up in auto-complete etc.

Andy also updated me that Jena 3 (with TopBraid 5.2) will include the math 
functions from

https://www.w3.org/TR/xpath-functions-31/

Thanks
Holger




On 7/06/2016 4:40, Steve Ray (CMU) wrote:

Seeing the release of TopBraid 5.1.4 reminded me that I would like to suggest 
the addition of the square root function to your standard library of math 
functions. I know others have bumped into this omission.

 

In the meantime, I went ahead and defined it with the following code:

 

rules:sqrt

  rdf:type spin:Function ;

  spin:constraint [

  rdf:type spl:Argument ;

  spl:predicate sp:arg1 ;

] ;

  spin:returnType xsd:float ;

  spinx:javaScriptCode "return Math.sqrt (arg1)"^^xsd:string ;

  rdfs:comment "Compute the square root of a number."^^xsd:string ;

  rdfs:subClassOf spin:Functions ;

 

…which requires importing http://spinrdf.org/spinx (from 
/TopBraid/SPIN/spinx.ttl)

 

I know it’s easy for users to just do this, but many people may not want to 
figure out how to bring in javascript snippets and locate the Math library.

 

Of course, you would use a different prefix than “rules” which I did.

 

 

- Steve

 

Steven R. Ray, Ph.D.

Distinguished Research Fellow

Carnegie Mellon University

NASA Research Park

Building 23 (MS 23-11)

P.O. Box 1
Moffett Field, CA 94305-0001

Email:steve@sv.cmu.edu

Phone: (650) 587-3780

Cell:  (202) 316-6481

Skype: steverayconsulting

cid:A9ED74CE-68DA-4276-847C-3C08B21B97C0@wv.cc.cmu.edu

 

-- 
You received this message because you are subscribed to the Google Group 
"TopBraid Suite Users", the topics of which include the TopBraid Suite family 
of products and its base technologies such as SPARQLMotion, SPARQL Web Pages 
and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

-- 
You received this message because you are subscribed to the Google Group 
"TopBraid Suite Users", the topics of which include the TopBraid Suite family 
of products and its base technologies such as SPARQLMotion, SPARQL Web Pages 
and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Group 
"TopBraid Suite Users", the topics of which include the TopBraid Suite family 
of products and its base technologies such as SPARQLMotion, SPARQL Web Pages 
and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [topbraid-users] general constraint checking 'library'?

2016-06-07 Thread Holger Knublauch

Hi Jack,

in SPIN we have the SPL library that is supposed to contain "standard" 
constraint types as SPIN templates. Right now it includes:


spl:CountPropertyConstraintTemplates
spl:ExistencePropertyPairConstraint
spl:LessThanOtherPropertyPairConstraint
spl:NonExistencePropertyPairConstraint
spl:ObjectCountPropertyConstraint
spl:PrimaryKeyPropertyConstraint
spl:PropertyConstraintTemplates
spl:PropertyPairConstraintTemplates
spl:RangePropertyConstraint
spl:RegexPropertyConstraint
spl:StringLengthPropertyConstraint
spl:TypePropertyConstraint
spl:UniquePropertyValueConstraint
spl:UntypedObjectPropertyConstraint

Other than that, I would recommend looking into SHACL, which will have 
more support in TopBraid 5.2. Although it is still evolving it will have 
the advantage of being a W3C standard.


http://w3c.github.io/data-shapes/shacl/

HTH
Holger


On 8/06/2016 7:39, Jack Hodges wrote:
Topbraid Composer has several SPIN functions that are pretty specific 
to defining constraints for model testing. Examples are 
spl:instanceOf, spl:hasValueOfType, smf:definedIn, 
smf:min/maxCardinality, smf:qname, spif:localName, 
spin:constructViolations, spin:violatesConstraints, etc. It seems 
clear that some effort has been expended to create functions that 
could be used in a generic constraints 'library' (i.e., to validate 
type, cardinality, value, threshold, range, ...), but does such a 
library of SPIN functions and ASK templates already exist? I hate to 
reinvent the wheel...


Jack
--
You received this message because you are subscribed to the Google 
Group "TopBraid Suite Users", the topics of which include the TopBraid 
Suite family of products and its base technologies such as 
SPARQLMotion, SPARQL Web Pages and SPIN.

To post to this group, send email to topbraid-users@googlegroups.com
---
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 topbraid-users+unsubscr...@googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Group "TopBraid 
Suite Users", the topics of which include the TopBraid Suite family of products and 
its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [topbraid-users] extending SM Module

2016-06-07 Thread Holger Knublauch

Hi German,

see the attached example. The key is to define a new helper function 
which takes two arguments and has a SPARQLMotion script as its body.




The new function can then be inserted into any other SM script from the 
Functions section, as a lego block.


Using SPIN constructors would not have the desired effect because it 
would be at module-creation time, not at run-time (which is what I 
believe you want).


HTH
Holger


On 7/06/2016 21:25, german.pete...@gmail.com wrote:

Hi,

I would like to to specialize existing SM module, by binding some of 
its arguments. More concretely, i would like to create module 
my:ImportGoogleSpreadsheetCSV by extending module 
sml:ImportFileFromURL. my:ImportGoogleSpreadsheetCSV should have 2 
additional parameters -- documentId and sheetId. This is my definition 
of the module :


my:ImportGoogleSpreadsheetCSV
  rdf:type sm:Module ;
  spin:constraint [
  rdf:type spl:Argument ;
  spl:predicate sml:documentId ;
  spl:valueType xsd:string ;
  rdfs:comment "Document Id."^^xsd:string ;
] ;
  spin:constraint [
  rdf:type spl:Argument ;
  spl:predicate sml:sheetId ;
  spl:valueType xsd:string ;
  rdfs:comment "Spreadsheet id."^^xsd:string ;
] ;
  spin:constructor [
  rdf:type sp:Construct ;
  sp:templates (
  [
sp:object [
sp:varName "url"^^xsd:string ;
  ] ;
sp:predicate sml:url ;
sp:subject spin:_this ;
  ]
) ;
  sp:text """CONSTRUCT {
   ?this sml:url ?url .
}
WHERE {
 BIND(CONCAT(\"https://docs.google.com/spreadsheets/d/\";, ?documentId, 
\"/export?format=csv&gid=\", ?sheetId) as ?url)

}"""^^xsd:string ;
  sp:where (
  [
rdf:type sp:Bind ;
sp:expression [
rdf:type sp:concat ;
sp:arg1 "https://docs.google.com/spreadsheets/d/"; ;
sp:arg2 [
sp:varName "documentId"^^xsd:string ;
  ] ;
sp:arg3 "/export?format=csv&gid=" ;
sp:arg4 [
sp:varName "sheetId"^^xsd:string ;
  ] ;
  ] ;
sp:variable [
sp:varName "url"^^xsd:string ;
  ] ;
  ]
) ;
] ;
  rdfs:label "Import CSV from Google Spreadsheet"^^xsd:string ;
  rdfs:subClassOf sml:ImportFileFromURL ;
.


Idea is to use CONCAT function to bind ?url in spin:constructor. 
However,  It gives me error: "Operation failed: 
org.topbraid.spin.sparqlmotion.modules.SMException: the string value 
is missing for url". This is clearly because sml:ImportFileFromURL 
module has "sml:url" argument which is required.


It there any way to disable required argument ? Is it correct way to 
do it ? Are there any other options to do it ?


Cheers,
Peter


--
You received this message because you are subscribed to the Google 
Group "TopBraid Suite Users", the topics of which include the TopBraid 
Suite family of products and its base technologies such as 
SPARQLMotion, SPARQL Web Pages and SPIN.

To post to this group, send email to topbraid-users@googlegroups.com
---
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 topbraid-users+unsubscr...@googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Group "TopBraid 
Suite Users", the topics of which include the TopBraid Suite family of products and 
its base technologies such as SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
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 topbraid-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# baseURI: http://example.org/sm/GoogleSpreadsheetCSV
# imports: http://topbraid.org/sparqlmotionfunctions
# imports: http://topbraid.org/sparqlmotionlib-tbc
# prefix: gocsv

@prefix arg:  .
@prefix gocsv:  .
@prefix owl:  .
@prefix rdf:  .
@prefix rdfs:  .
@prefix sm:  .
@prefix sml:  .
@prefix sp:  .
@prefix spin:  .
@prefix spl:  .
@prefix xsd:  .


  rdf:type owl:Ontology ;
  owl:imports  ;
  ow