Dear Chavdar,

SHACL SPARQL is not in the Advanced Features. It is in the main SHACL 
Specification. SHACL API coverage is described in GitHub.

SPARQL-based targets are in the Advanced features, but I do not know if you 
need them. 

If you use SHACL SPARQL and/or SPARQL based targets, then yes, you would need 
to carefully consider your queries and performance.

Below are some questions and possible pointers.

You do not have to answer these questions for me as I am not likely to have 
time to help you with this project. They are just a food for thought.

It may be that someone else on this mailing list will have time to help.

Regards,

Irene

> On Aug 10, 2020, at 2:47 PM, Chavdar Ivanov <ch.iva...@gmail.com> wrote:
> 
> Dear all,
> 
> I am trying to use the API to define some constraints and figure out that for 
> many I need to use SPARQL
> 
> I was given some reference to the SHACL Advanced Features 1.1 but I am not 
> sure if this is already supported by TopBraid API that is now posted in Maven
> 
> In order to illustrate what I need to do I attached some sample data xml and 
> ttl that are same (just different format ). I would like to give some hints 
> on how I could do the following constraints. I guess the target will need to 
> be carefully selected and the query might need to have subquery.
> 
> - constraint 1
> 
> Only one Class1 has attribute1 that is the highest value(non-zero) and all 
> others shall be equal to 0
> 
> This should also check if the highest value is appearing once i.e. not ok if 
> attribute1 is 2 in one instance and 2 in the other
> 

Not sure I understand. Only one member of Class 1 has a non zero value for 
attribute 1?

If so, you could use sh:targetObjectsOf to target nodes that are subjects of 
the attribute 1 and use sh:or to say that if the target value is not zero, then 
there is only 1 subject that is a member of Class 1.
>  
> 
> - constraint 2
> 
> Class3.attribute1 shall be equal to one of the associated Class2.attribute1 
> values.
> 
> Here I wanted to have a List of all Class2.attribute1 values and just filter 
> if Class3.attribute1 is IN or NOT IN
> 
> The question is how to iterate to build the list. Or maybe the list idea is a 
> wrong approach to this.
> 

Do you meant that for a member of Class 3, value of the attribute 1 has to be 
the same as the value of attribute 1 for an associated member of Class 3? What 
is the relationship between these resources?

You may be able to use a complex path with sh:equals 
https://www.w3.org/TR/shacl/#EqualsConstraintComponent 
<https://www.w3.org/TR/shacl/#EqualsConstraintComponent>.


>  
> 
> - constraint 3
> 
> Instances of Class4 are required (Violation) to be instantiated for Class3 
> and Class5. If Class4 is instantiated for Class2 the severity is Info.
> 
> In addition looking at Class3 how I can count how many instances of Class2 
> are associated via Class2.Class3. I guess GROUP BY can be used.
> 
>  
> 
No idea what this means. What does it mean for instances of Class 4 to be 
instantiated for Class 3? 

Is there some relationship between members of these classes? And for a member 
of Class 3, the value of relationship must exist and must be a resource that is 
a member of Class 4? If so, this is a straight forward sh:class and sh:maxCount 
constraints on the relationship at Class 3.

Or are you taking about a situation where an instance of Class4 must also be of 
type 3 and 5?
> -Constraint 4
> 
> Class4 is instantiated only for instances that are referenced by Class6
> 

Again, do not understand the language
>  
> 
> -Constraint 5
> 
> If only one instance of Class7 is associated with Class2 instance then 
> Class7.attribute1 shall equal Class2.attribute2
> 
Not enough information e.g., what is a relationship between these classes and 
are values of this relationship for Class7 always members of Class 2 or could 
there be some other values? If latter than you would need to look at qualified 
value shapes.

 think this is sh:or

Again, not sure if you need SPARQL or could create something using sh:or, 
sh:equals and, possibly, sh:values property rule.
>  
> 
> - Constraint 6
> check if Class3 is referenced by at least 3 instances of Class2

This is maxCount on the connecting property, but, again, the question is if all 
values belong to the same class or could there be 3 values of one and 2 values 
of another and that is still valid. Then, you need to look at the qualified 
value shapes.

> and there should be one instance Class2 for which Class2.attribute1 is 
> negative and another instance of Class2 for which Class2.attribute2 is 
> positive 

This is definitely qualified value shapes 
https://www.w3.org/TR/shacl/#QualifiedValueShapeConstraintComponent 
<https://www.w3.org/TR/shacl/#QualifiedValueShapeConstraintComponent>
> 
> 
> Best regards
> Chavdar 
> 
> -- 
> 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 
> <mailto:topbraid-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/topbraid-users/de8f635c-9777-44ae-98e1-fde322145f80o%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/topbraid-users/de8f635c-9777-44ae-98e1-fde322145f80o%40googlegroups.com?utm_medium=email&utm_source=footer>.
> <Example.ttl><Example.xml>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/5CA2E71F-FCC9-477E-B166-409A5B94AB91%40topquadrant.com.

Reply via email to