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

shaclc->shacl outputs ; instead of . #91

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

shaclc->shacl outputs ; instead of . #91

VladimirAlexiev opened this issue May 14, 2020 · 5 comments

Comments

@VladimirAlexiev
Copy link

Hi @HolgerKnublauch !

I have this test file: property-2-values-and.shacl:

@base <http://example.org/property-or-2> .
@prefix ex: <http://example.org/test#> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .

<>
	a owl:Ontology ;
.

ex:TestShape
	a sh:NodeShape ;
	sh:property [
		sh:path ex:property1 ;
		sh:hasValue ex:value1 ;
	] ;
	sh:property [
		sh:path ex:property1 ;
		sh:hasValue ex:value2 ;
	] ;
.

Then I convert it to SHACL using code by @yasengmarinov (we plan to release it shortly):

    shaclcWriter.write(
        getOutputStream(), RDFDataMgr.loadGraph(inputFile, TURTLE), new PrefixMapStd(), BASE, null);

The result is property-2-values-and.shaclc:

BASE <http://example.org/>

shape ex:TestShape {
	ex:property1  [0..*] hasValue=ex:value2 ;
	ex:property1  [0..*] hasValue=ex:value1 ;
}

And has two problems:

  • line endings are ; but should be .
  • the PREFIX-es are missing

Trying to parse this as SHACLC returns these errors:

line 4:41 token recognition error at: ';'
line 5:41 token recognition error at: ';'
line 6:0 mismatched input '}' expecting {'Literal', '{', 'maxLength', 'qualifiedMaxCount', 'deactivated', 'qualifiedMinCount', 'maxExclusive', 'languageIn', 'minLength', 'equals', 'hasValue', '@', 'BlankNodeOrLiteral', 'datatype', 'qualifiedValueShape', 'disjoint', 'message', 'IRI', 'BlankNodeOrIRI', 'closed', 'nodeKind', 'severity', 'qualifiedValueShapesDisjoint', 'class', 'uniqueLang', 'maxInclusive', 'flags', 'lessThan', '.', 'minInclusive', '[', 'ignoredProperties', 'IRIOrLiteral', '|', 'pattern', '!', 'in', 'minExclusive', 'BlankNode', 'lessThanOrEquals', IRIREF, PNAME_NS, PNAME_LN, ATPNAME_NS, ATPNAME_LN}
Exception in thread "main" java.lang.RuntimeException: Undefined prefixed name ex:TestShape
@HolgerKnublauch
Copy link
Collaborator

Hi Valdimir, I am very glad to see some interest in SHACLC. I needed some down-time this weekend and didn't yet have a chance to get to your questions, but will try to reach them in the next few days. Apologies for the delay.

@HolgerKnublauch
Copy link
Collaborator

The prefixes are empty because your code just uses new PrefixMapStd() which is empty I guess.

You are right about the ; which was a left-over from previous versions of the spec. I have changed it to '.' hopefully resolving this ticket.

Note that the SHACLC writer is really just a toy and will not work for many if not most real SHACL files. I regard the Compact Syntax as a decent way of getting definitions INTO a system, but not as an output format.

@VladimirAlexiev
Copy link
Author

Compact Syntax .. not as an output format.

Compact is 3x briefer than Normal and much nicer to work with, not least because the ANTL grammar gives useful error messages, which can be used to highlight errors eg in Emacs flycheck.

So if I get a bunch of Normal files and need to edit them, I'd first convert to Compact. I think this inverse conversion is also useful.

@HolgerKnublauch
Copy link
Collaborator

Yes, the Antlr argument is valid during editing, and that's perfectly fine. Quickly drafting shape trees is good with the compact syntax.

I meant the case where you have no SHACLC to begin with and need to edit that. Once you convert them to SHACLC you'll possibly loose triples because SHACL is much richer than that.

@VladimirAlexiev VladimirAlexiev changed the title shaclc conversion: missing prefixes, outputs ; instead of . shaclc->shacl outputs ; instead of . Jun 11, 2020
@VladimirAlexiev
Copy link
Author

closing this, making a new one for the leftover issues

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