@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://example.com/ns#> .
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:IRIShape a sh:NodeShape ;
  sh:nodeKind sh:IRI .

ex:IRIListShape
  rdf:type sh:NodeShape ;
  sh:memberShape ex:IRIShape ;
  sh:targetNode ex:list0 ;
  # Valid empty list
  sh:targetNode rdf:nil ;
  # ex:list1 is valid, the remainder trigger violations (including ex:list3 which has no properties in this graph)
  sh:targetNode ex:list1, ex:list2, ex:list3, ex:list4, ex:list5, ex:list6, ex:list7, ex:list9 ;
.

ex:list0
  rdf:first ex:Alice ;
  rdf:rest (
    ex:Bob
  ) ;
.

ex:list1
  rdf:first ex:Alice ;
  rdf:rest rdf:nil ;
  ex:extraProperty "extra" ;
.

ex:list2
  rdf:first ex:Alice ;
  rdf:rest (
    "Bob"
  )
.

ex:list4
  rdf:first ex:Alice ;
.

ex:list5
  rdf:first "Charlie" ;
  rdf:rest (
    "Donna"
  )
.

ex:list6
  rdf:first "Charlie" ;
.

ex:list8 rdfs:label "Malformed SHACL List" .

ex:list7
  rdf:first "Charlie" ;
  rdf:rest ex:list8 ;
.

# using ex:list9 and ex:list10 to test recursive list error
ex:list9
  rdf:first ex:Alice ;
  rdf:rest ex:list10 ;
.

ex:list10
  rdf:first "Bob" ;
  rdf:rest ex:list9 .

<>
  rdf:type mf:Manifest ;
  mf:entries (
      <memberShape-001>
    ) ;
.

<memberShape-001>
  rdf:type sht:Validate ;
  rdfs:label "Test of sh:memberShape on node shape 001" ;
  mf:action [
      sht:dataGraph <> ;
      sht:shapesGraph <> ;
    ] ;
  mf:result [
      rdf:type sh:ValidationReport ;
      sh:conforms "false"^^xsd:boolean ;
      sh:result [
          rdf:type sh:ValidationResult ;
          sh:focusNode ex:list2 ;
          sh:resultSeverity sh:Violation ;
          sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
          sh:sourceShape ex:IRIListShape ;
          sh:value ex:list2 ;
          sh:detail [
            rdf:type sh:ValidationResult ;
            sh:focusNode "Bob" ;
            sh:resultSeverity sh:Violation ;
            sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
            sh:sourceShape ex:IRIShape ;
            sh:value "Bob" ;
          ] ;
        ] ;
      sh:result [
          rdf:type sh:ValidationResult ;
          sh:focusNode ex:list3 ;
          sh:resultSeverity sh:Violation ;
          sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
          sh:sourceShape ex:IRIListShape ;
          sh:value ex:list3 ;
        ] ;
      sh:result [
          rdf:type sh:ValidationResult ;
          sh:focusNode ex:list4 ;
          sh:resultSeverity sh:Violation ;
          sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
          sh:sourceShape ex:IRIListShape ;
          sh:value ex:list4 ;
        ] ;
      sh:result [
          rdf:type sh:ValidationResult ;
          sh:focusNode ex:list5 ;
          sh:resultSeverity sh:Violation ;
          sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
          sh:sourceShape ex:IRIListShape ;
          sh:value ex:list5 ;
          sh:detail [
            rdf:type sh:ValidationResult ;
            sh:focusNode "Charlie" ;
            sh:resultSeverity sh:Violation ;
            sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
            sh:sourceShape ex:IRIShape ;
            sh:value "Charlie" ;
          ], [
            rdf:type sh:ValidationResult ;
            sh:focusNode "Donna" ;
            sh:resultSeverity sh:Violation ;
            sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
            sh:sourceShape ex:IRIShape ;
            sh:value "Donna" ;
          ]
        ] ;
      sh:result [
          rdf:type sh:ValidationResult ;
          sh:focusNode ex:list6 ;
          sh:resultSeverity sh:Violation ;
          sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
          sh:sourceShape ex:IRIListShape ;
          sh:value ex:list6 ;
        ] ;
      sh:result [
          rdf:type sh:ValidationResult ;
          sh:focusNode ex:list7 ;
          sh:resultSeverity sh:Violation ;
          sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
          sh:sourceShape ex:IRIListShape ;
          sh:value ex:list7 ;
        ] ;
      sh:result [
          rdf:type sh:ValidationResult ;
          sh:focusNode ex:list9 ;
          sh:resultSeverity sh:Violation ;
          sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
          sh:sourceShape ex:IRIListShape ;
          sh:value ex:list9 ;
        ] ;
    ] ;
  mf:status sht:approved ;
. 
