@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/sparql/pre-binding/pre-binding-002.test#> .
@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:
	sh:declare [
		sh:prefix "ex" ;
		sh:namespace "http://datashapes.org/sh/tests/sparql/pre-binding/pre-binding-002.test#"^^xsd:anyURI ;
	] .

ex:TestShape
  rdf:type sh:NodeShape ;
  rdfs:label "Test shape" ;
  sh:sparql ex:TestShape-sparql ;
  sh:targetNode ex:InvalidResource ;
.
ex:TestShape-sparql
  sh:prefixes ex: ;
  sh:select """
  	SELECT $this
	WHERE {
		{
			FILTER (false) .
		}
		UNION
		{
			FILTER ($this = ex:InvalidResource) .
		}
	}""" ;
.
ex:ValidResource1
  rdf:type rdfs:Resource ;
.
<>
  rdf:type mf:Manifest ;
  mf:entries (
      <pre-binding-002>
    ) ;
.
<pre-binding-002>
  rdf:type sht:Validate ;
  rdfs:label "Test of pre-binding in UNION" ;
  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:InvalidResource ;
          sh:resultSeverity sh:Violation ;
          sh:sourceConstraint ex:TestShape-sparql ;
          sh:sourceConstraintComponent sh:SPARQLConstraintComponent ;
          sh:sourceShape ex:TestShape ;
          sh:value ex:InvalidResource ;
        ] ;
    ] ;
  mf:status sht:approved ;
.
