title: RDF4j Shacl validation gives different results for Turtle and JSON-LD
body: <p>I have a problem with RDF4J SHACL validation engine.</p>
  <p>This is my code where I use shacl rules and example payload files as TTL input:</p>
  <pre><code>String SHAPES = &quot;rules.ttl&quot;;
  String DATA = &quot;input.ttl&quot;;
  
  ShaclSail shaclSail = new ShaclSail(new MemoryStore());
  Repository repo = new SailRepository(shaclSail);
  
  try (RepositoryConnection connection = repo.getConnection()) {
      connection.begin();
      connection.add(new StringReader(Files.readString(Path.of(SHAPES))), RDFFormat.TURTLE, RDF4J.SHACL_SHAPE_GRAPH);
      connection.commit();
  
      connection.begin();
      connection.add(new StringReader(Files.readString(Path.of(DATA))), RDFFormat.TURTLE);
      connection.commit();
  
      connection.begin();
      connection.clear(RDF4J.SHACL_SHAPE_GRAPH);
      connection.commit();
  
  } catch (Exception e) {
      Throwable cause = e.getCause();
      if (cause instanceof ValidationException) {
          Model validationReportModel = ((ValidationException) cause).validationReportAsModel();
          Rio.write(validationReportModel, System.out, RDFFormat.TURTLE);
      }
  }
  </code></pre>
  <p>The shacl rules file looks like following:</p>
  <pre><code>@prefix owl: &lt;http://www.w3.org/2002/07/owl#&gt; .
  @prefix rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
  @prefix xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt; .
  @prefix shacl: &lt;http://www.w3.org/ns/shacl#&gt; .
  ​
  &lt;http://example.com/Property&gt;
    a owl:DatatypeProperty, rdf:Property  .
  ​
  &lt;http://example.com/Class&gt;
    a owl:Class .
  ​
  &lt;http://example.com/ClassShape&gt;
    a &lt;http://www.w3.org/ns/shacl#NodeShape&gt; ;
    shacl:property &lt;http://example.com/PropertyShape&gt; ;
    shacl:targetClass &lt;http://example.com/Class&gt; .
  ​
  &lt;http://example.com/PropertyShape&gt;
    a shacl:PropertyShape ;
    shacl:datatype xsd:integer ;
    shacl:maxCount 1 ;
    shacl:minCount 1 ;
    shacl:path &lt;http://example.com/Property&gt; .
  </code></pre>
  <p>and the input file:</p>
  <pre><code>&lt;http://example.com/1&gt;
    a &lt;http://example.com/Class&gt; ;
    &lt;http://example.com/Property&gt; &quot;test&quot; .
  </code></pre>
  <p>The above snippet returns a proper datatype violation results as <code>&lt;http://example.com/Property&gt; &quot;test&quot; .</code> is not an integer as defined in the rules: <code>shacl:datatype xsd:integer ;</code>. This is a behaviour that I expect.</p>
  <p>But when I use exactly the same data but in JSON-LD format:</p>
  <pre><code>...
  connection.add(new StringReader(Files.readString(Path.of(SHAPES))), RDFFormat.JSONLD, RDF4J.SHACL_SHAPE_GRAPH);
  ...
  connection.add(new StringReader(Files.readString(Path.of(DATA))), RDFFormat.JSONLD);
  ...
  </code></pre>
  <p>with this rules file:</p>
  <pre><code>{
    &quot;@context&quot;: {
      &quot;id&quot;: &quot;@id&quot;,
      &quot;type&quot;: &quot;@type&quot;,
      &quot;datatype&quot;: {
        &quot;@id&quot;: &quot;http://www.w3.org/ns/shacl#datatype&quot;,
        &quot;@type&quot;: &quot;@id&quot;
      },
      &quot;path&quot;: {
        &quot;@id&quot;: &quot;http://www.w3.org/ns/shacl#path&quot;,
        &quot;@type&quot;: &quot;@id&quot;
      },
      &quot;class&quot;: {
        &quot;@id&quot;: &quot;http://www.w3.org/ns/shacl#class&quot;,
        &quot;@type&quot;: &quot;@id&quot;
      },
      &quot;property&quot;: {
        &quot;@id&quot;: &quot;http://www.w3.org/ns/shacl#property&quot;,
        &quot;@type&quot;: &quot;@id&quot;,
        &quot;@container&quot;: &quot;@set&quot;
      },
      &quot;targetClass&quot;: {
        &quot;@id&quot;: &quot;http://www.w3.org/ns/shacl#targetClass&quot;,
        &quot;@type&quot;: &quot;@id&quot;
      },
      &quot;maxCount&quot;: &quot;http://www.w3.org/ns/shacl#maxCount&quot;,
      &quot;minCount&quot;: &quot;http://www.w3.org/ns/shacl#minCount&quot;,
      &quot;PropertyShape&quot;: &quot;http://www.w3.org/ns/shacl#PropertyShape&quot;,
      &quot;Property&quot;: &quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#Property&quot;,
      &quot;NodeShape&quot;: &quot;http://www.w3.org/ns/shacl#NodeShape&quot;,
      &quot;Class&quot;: &quot;http://www.w3.org/2002/07/owl#Class&quot;,
      &quot;DatatypeProperty&quot;: &quot;http://www.w3.org/2002/07/owl#DatatypeProperty&quot;
    },
    &quot;@graph&quot;: [
      {
        &quot;id&quot;: &quot;http://example.com/Property&quot;,
        &quot;type&quot;: [
          &quot;DatatypeProperty&quot;,
          &quot;Property&quot;
        ]
      },
      {
        &quot;id&quot;: &quot;http://example.com/Class&quot;,
        &quot;type&quot;: &quot;Class&quot;
      },
      {
        &quot;id&quot;: &quot;http://example.com/ClassShape&quot;,
        &quot;type&quot;: &quot;NodeShape&quot;,
        &quot;property&quot;: [
          &quot;http://example.com/PropertyShape&quot;
        ],
        &quot;targetClass&quot;: &quot;http://example.com/Class&quot;
      },
      {
        &quot;id&quot;: &quot;http://example.com/PropertyShape&quot;,
        &quot;type&quot;: &quot;PropertyShape&quot;,
        &quot;datatype&quot;: &quot;http://www.w3.org/2001/XMLSchema#integer&quot;,
        &quot;maxCount&quot;: 1,
        &quot;minCount&quot;: 1,
        &quot;path&quot;: &quot;http://example.com/Property&quot;
      }
    ]
  }
  </code></pre>
  <p>and content file:</p>
  <pre><code>{
      &quot;@context&quot;: {
          &quot;Class&quot;: &quot;http://example.com/Class&quot;,
          &quot;property&quot;: {
              &quot;@id&quot;: &quot;http://example.com/Property&quot;,
              &quot;@type&quot;: &quot;http://www.w3.org/2001/XMLSchema#integer&quot;
          }
      },
      &quot;@graph&quot;: {
          &quot;@type&quot;: &quot;Class&quot;,
          &quot;@id&quot;: &quot;http://example.com/1&quot;,
          &quot;property&quot;: &quot;test&quot;
      }
  }
  </code></pre>
  <p>I get no violations which is very surprising as other SHACL engines line Apache Jena or online <a href="https://shacl.org/playground/" rel="nofollow noreferrer">https://shacl.org/playground/</a> are returning proper datatype violation.</p>
  <p>I get datatype violation when I remove the <code>property</code> type from the @context:</p>
  <pre><code>&quot;@type&quot;: &quot;http://www.w3.org/2001/XMLSchema#integer&quot;
  </code></pre>
  <p>or change the <code>property</code> to an ObjectProperty:</p>
  <pre><code>&quot;property&quot;: {
    &quot;@id&quot;: &quot;http://example.com/property1&quot;
    ...
  }
  </code></pre>
  <p>but there are no datatype violations when I for example use string instead of an integer.</p>
  <p>Is this a bug in RDF4J or expected behaviour?</p>