-
Notifications
You must be signed in to change notification settings - Fork 0
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
Parsing ontology file (.owl, serialized in RDF/XML) to JSON-LD #3
Comments
You may be missing some whitespace between the "xmlns" attributes inside of the rdf:RDF element declaration. |
You were right! Thank you for the help. One last question: If, instead I wanted to read the RDF/XML from a This is what I tried: final RDF2GoRDFParser parser = new RDF2GoRDFParser();
final Model modelResult = RDF2Go.getModelFactory().createModel().open();
modelResult.readFrom(new FileInputStream(ontologyFile), Syntax.RdfXml);
final Object jsonld = JsonLdProcessor.fromRDF(modelResult, parser);
Map con = new HashMap();
JsonLdOptions opt = new JsonLdOptions();
Object compact = JsonLdProcessor.compact(jsonld, con, opt);
String finalObj = JsonUtils.toPrettyString(jsonld);
System.out.println(finalObj); The ontology file I'm using is this: http://pastebin.com/BhHHx4RM I'm getting this error: [WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: Cannot cast a BlankNode to a URI
at org.ontoware.rdf2go.model.node.impl.AbstractBlankNodeImpl.asURI(AbstractBlankNodeImpl.java:49)
at com.github.jsonldjava.rdf2go.RDF2GoRDFParser.handleStatement(RDF2GoRDFParser.java:70)
at com.github.jsonldjava.rdf2go.RDF2GoRDFParser.importModel(RDF2GoRDFParser.java:40)
at com.github.jsonldjava.rdf2go.RDF2GoRDFParser.parse(RDF2GoRDFParser.java:127)
at com.github.jsonldjava.core.JsonLdProcessor.fromRDF(JsonLdProcessor.java:420)
at com.github.jsonldjava.core.JsonLdProcessor.fromRDF(JsonLdProcessor.java:456)
at luispcosta.db.Populate.storeOntology(Populate.java:85)
at luispcosta.db.Populate.main(Populate.java:61) I'm not sure if I need a special configuration on json-ld to read this ontology, or if is a specific problem in the ontology. I'm guessing it is a error in the ontology because of: |
That looks like a bug here as not all non-literal cases are URIs, but I am not familiar with the RDF2Go API: @ismriv may be able to help further with a fix for that. |
Great! I'll be glad to help out fixing the issue (if it is confirmed as one) as well. Will be waiting |
Hi @luispcosta, sorry I've just seen this now, I'm not actively involve in this anymore. Are you still having the same problem? There seems to be a bug in L70, can you try checking if the object is an instance of |
I'm having the same problem while parsing an RDF graph containing cardinality restriction.
L70 treats |
Hello.
I'm trying to create a simple program like the one presented here: https://github.com/jsonld-java/jsonld-java-rdf2go/blob/master/src/test/java/com/github/jsonldjava/rdf2go/RDF2GoRDFParserTest.java
If I understood correctly, RDF/XML is also a valid syntax to be transformed to JSON-LD (correct if I'm wrong) and so this is the code I wrote so far:
I'm sure that the Ontology encoded by the the string
RdfXml
is a valid one.However when I try to run this code, I always get:
So two questions:
Thank you!
Edit: If this actually works and I can solve the problem, I'll gladly open a PR with some tests of RDF/XML to JSON-LD transformations!
The text was updated successfully, but these errors were encountered: