Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shacl conversion: malformed lists #92

Closed
VladimirAlexiev opened this issue May 14, 2020 · 3 comments
Closed

shacl conversion: malformed lists #92

VladimirAlexiev opened this issue May 14, 2020 · 3 comments

Comments

@VladimirAlexiev
Copy link

Hi @HolgerKnublauch !

@yasengmarinov has written a command-line convertor (that we plan to release shortly)

  private void compactToNormal() throws IOException {
    SHACLCReader shaclcReader = new SHACLCReader();
    StringWriter writer = new StringWriter();
    OutputStream os = new WriterOutputStream(writer, Charset.defaultCharset());
    shaclcReader.read(
        readFile(inputFile), BASE, TURTLE, StreamRDFWriter.getWriterStream(os, TURTLE), null);
    Model model = ModelFactory.createDefaultModel();
    model.read(new StringReader(writer.toString()), BASE, "TTL");
    RDFDataMgr.write(getOutputStream(), model, RDFFormat.TURTLE_PRETTY);
  }

  private void normalToCompact() throws IOException {
    SHACLCWriter shaclcWriter = new SHACLCWriter();
    shaclcWriter.write(
        getOutputStream(), RDFDataMgr.loadGraph(inputFile, TURTLE), new PrefixMapStd(), BASE, null);
  }

I'm trying it on https://github.com/w3c/data-shapes/blob/gh-pages/shacl-compact-syntax/tests/valid/complex1.shaclc and we get different results.

Yours:

			sh:property [
				sh:path ex:postalCode ;
				sh:or ( [ sh:datatype xsd:integer ] [ sh:datatype xsd:string ] ) ;
				sh:minCount 1 ;
				sh:maxCount 1 ;
				sh:maxLength 5 ;
			] ;

Ours:

                                             [ sh:property  [ sh:maxCount  1 ;
                                                              sh:minCount  1 ;
                                                              sh:path      ex:postalCode
                                                            ] ;
 ...  ...  ...
[ rdf:first _:b0 ; rdf:rest ( [ sh:datatype  xsd:string ]
                            ) ] .
_:b1    rdf:first  _:b0 ;
        rdf:rest   _:b2 .

Are we making some mistake? Given #91 and comparing to the tests above, it seems there is some regression in the latest version 1.3.2 ?

@HolgerKnublauch
Copy link
Collaborator

I could not reproduce a problem with that file and still get the same output as in the test case. I also don't recognize recent changes to our code base or the SHACLC parser code base online. The example you pasted is incomplete, unfortunately, e.g. I wonder what happened to the sh:maxLength triple.

It's an open source project, so my suggestion is you try walk through the code with a debugger, e.g. breakpointing at SHACLCReader.parsePropertyOr to see where it produces what looks like detached bnodes.

@VladimirAlexiev
Copy link
Author

@HolgerKnublauch thanks for the input! Can you point to the code you use to do the conversion?

The example you pasted is incomplete, unfortunately, e.g. I wonder what happened to the sh:maxLength triple

Yes, it's missing, and sh:datatype xsd:integer is missing, the sh:or is missing and its list is disconnected.

Here's another symptom: this SHACLC

PREFIX : <http://example.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

shapeClass :Project {
  :hasEvent @:ProjectOpenEvent [1..1].
}

shapeClass :ProjectOpenEvent {
  :hasDate xsd:date [1..1].
}

produces this SHACL where the second shape is missing:

:ProjectOpenEvent  a   rdfs:Class , sh:NodeShape ;
        sh:property  []  .

:Project  a            rdfs:Class , sh:NodeShape ;
        sh:property  [ sh:maxCount  1 ;
                       sh:minCount  1 ;
                       sh:node      :ProjectOpenEvent ;
                       sh:path      :hasEvent
                     ] .

@yasengmarinov can you spend some time to debug this?

@HolgerKnublauch
Copy link
Collaborator

Closing old issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants