Skip to content

graph.Parse() creates a lot of blank nodes when parsing the official SHACL tests #19

@utrack

Description

@utrack

Hi there! Thanks for supporting this 👍

I'm trying to parse the SHACL test suite in TTL format, but the output gives me a hell of a lot blank nodes. Can you please check why that's happening/did I do something wrong?

Test that I'm trying to parse: https://github.com/w3c/data-shapes/blob/gh-pages/data-shapes-test-suite/tests/core/property/and-001.ttl

Go code:

	g := rdf2go.NewGraph("", false)

	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}

	err = g.Parse(f, "text/turtle")
	if err != nil {
		return nil, err
	}


	var buf bytes.Buffer
	err = g.Serialize(&buf, "text/turtle")
	if err != nil {
		t.Fatal(err)
	}

	os.WriteFile("testmanual_result.ttl", buf.Bytes(), 0644)

Result (testmanual_result.ttl):

Details

_:a1
  <http://www.w3.org/ns/shacl#property> _:a2 .<http://datashapes.org/sh/tests/core/node/and-001.test#ValidRectangle1>
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://datashapes.org/sh/tests/core/node/and-001.test#Rectangle> ;
  <http://datashapes.org/sh/tests/core/node/and-001.test#width> "2"^^<http://www.w3.org/2001/XMLSchema#integer> ;
  <http://datashapes.org/sh/tests/core/node/and-001.test#height> "3"^^<http://www.w3.org/2001/XMLSchema#integer> ._:a6
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> ;
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> </and-001> ._:a8
  <http://www.w3.org/ns/shacl#result> _:a10 ;
  <http://www.w3.org/ns/shacl#conforms> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> ;
  <http://www.w3.org/ns/shacl#result> _:a9 ;
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/shacl#ValidationReport> ._:a10
  <http://www.w3.org/ns/shacl#sourceConstraintComponent> <http://www.w3.org/ns/shacl#AndConstraintComponent> ;
  <http://www.w3.org/ns/shacl#resultSeverity> <http://www.w3.org/ns/shacl#Violation> ;
  <http://www.w3.org/ns/shacl#sourceShape> <http://datashapes.org/sh/tests/core/node/and-001.test#Rectangle> ;
  <http://www.w3.org/ns/shacl#focusNode> <http://datashapes.org/sh/tests/core/node/and-001.test#InvalidRectangle2> ;
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/shacl#ValidationResult> ;
  <http://www.w3.org/ns/shacl#value> <http://datashapes.org/sh/tests/core/node/and-001.test#InvalidRectangle2> .<http://datashapes.org/sh/tests/core/node/and-001.test#InvalidRectangle2>
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://datashapes.org/sh/tests/core/node/and-001.test#Rectangle> ;
  <http://datashapes.org/sh/tests/core/node/and-001.test#width> "2"^^<http://www.w3.org/2001/XMLSchema#integer> .<http://datashapes.org/sh/tests/core/node/and-001.test#Rectangle>
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> ;
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/shacl#NodeShape> ;
  <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://www.w3.org/2000/01/rdf-schema#Resource> ;
  <http://www.w3.org/ns/shacl#and> _:a0 ._:a0
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:a3 ;
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:a1 ._:a5
  <http://www.w3.org/ns/shacl#minCount> "1"^^<http://www.w3.org/2001/XMLSchema#integer> ;
  <http://www.w3.org/ns/shacl#path> <http://datashapes.org/sh/tests/core/node/and-001.test#height> ._:a3
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:a4 ;
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .<>
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#Manifest> ;
  <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#entries> _:a6 ._:a2
  <http://www.w3.org/ns/shacl#minCount> "1"^^<http://www.w3.org/2001/XMLSchema#integer> ;
  <http://www.w3.org/ns/shacl#path> <http://datashapes.org/sh/tests/core/node/and-001.test#width> ._:a9
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/shacl#ValidationResult> ;
  <http://www.w3.org/ns/shacl#sourceConstraintComponent> <http://www.w3.org/ns/shacl#AndConstraintComponent> ;
  <http://www.w3.org/ns/shacl#focusNode> <http://datashapes.org/sh/tests/core/node/and-001.test#InvalidRectangle1> ;
  <http://www.w3.org/ns/shacl#sourceShape> <http://datashapes.org/sh/tests/core/node/and-001.test#Rectangle> ;
  <http://www.w3.org/ns/shacl#resultSeverity> <http://www.w3.org/ns/shacl#Violation> ;
  <http://www.w3.org/ns/shacl#value> <http://datashapes.org/sh/tests/core/node/and-001.test#InvalidRectangle1> .<http://datashapes.org/sh/tests/core/node/and-001.test#InvalidRectangle1>
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://datashapes.org/sh/tests/core/node/and-001.test#Rectangle> ;
  <http://datashapes.org/sh/tests/core/node/and-001.test#height> "3"^^<http://www.w3.org/2001/XMLSchema#integer> ._:a7
  <http://www.w3.org/ns/shacl-test#dataGraph> <> ;
  <http://www.w3.org/ns/shacl-test#shapesGraph> <> ._:a4
  <http://www.w3.org/ns/shacl#property> _:a5 .</and-001>
  <http://www.w3.org/2000/01/rdf-schema#label> "Test of sh:and at node shape 001" ;
  <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result> _:a8 ;
  <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action> _:a7 ;
  <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#status> <http://www.w3.org/ns/shacl-test#approved> ;
  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/shacl-test#Validate> .

Tree explorer at https://www.semantechs.co.uk/turtle-editor-viewer/ :

Before

Image

After

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions