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

TurtleDocumentFormat: can't parse PREFIX #1149

Open
sszuev opened this issue Aug 4, 2024 · 0 comments
Open

TurtleDocumentFormat: can't parse PREFIX #1149

sszuev opened this issue Aug 4, 2024 · 0 comments

Comments

@sszuev
Copy link
Contributor

sszuev commented Aug 4, 2024

PREFIX is a modern alternative for @prefix: https://www.w3.org/TR/turtle/#turtle-prefixes

following testcase fails with exception:

        String ttl = """
                PREFIX dc:   <http://purl.org/dc/elements/1.1/>
                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 xsd:  <http://www.w3.org/2001/XMLSchema#>
                """;
        OWLOntology owl = OntManagers.createOWLAPIImplManager().loadOntologyFromOntologyDocument(
                new StringDocumentSource(ttl, IRI.create("x"), new TurtleDocumentFormat(), "ttl")
        );
        owl.saveOntology(System.out);
Exception in thread "main" org.semanticweb.owlapi.io.UnparsableOntologyException: Problem parsing x
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.
The following parsers were tried:
1) org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser@724f138e


Detailed logs:
--------------------------------------------------------------------------------
Parser: org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser@724f138e
    Stack trace:
org.semanticweb.owlapi.rdf.turtle.parser.ParseException: Encountered unexpected token: "PREFIX" <PN_LOCAL>
    at line 1, column 1.

Was expecting one of:

    "("
    "@base"
    "@prefix"
    "["
    <EMPTY_BLANK_NODE>
    <FULLIRI>
    <NODEID>
    <PNAME_LN>
    <PNAME_NS>
        org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser.parse(TurtleOntologyParser.java:58)
        uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:195)
        uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1105)
        uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1055)
        uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1005)
        com.github.owlcs.ontapi.tmp.TmpTurtleInvestigation.main(TmpTurtleInvestigation.java:25)
Encountered unexpected token: "PREFIX" <PN_LOCAL>
    at line 1, column 1.

Was expecting one of:

    "("
    "@base"
    "@prefix"
    "["
    <EMPTY_BLANK_NODE>
    <FULLIRI>
    <NODEID>
    <PNAME_LN>
    <PNAME_NS>
        org.semanticweb.owlapi.rdf.turtle.parser.TurtleParser.generateParseException(TurtleParser.java:1034)
        org.semanticweb.owlapi.rdf.turtle.parser.TurtleParser.jj_consume_token(TurtleParser.java:902)
        org.semanticweb.owlapi.rdf.turtle.parser.TurtleParser.parseDocument(TurtleParser.java:165)
        org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParser.parse(TurtleOntologyParser.java:54)
        uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:195)
        uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1105)
        uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1055)
        uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1005)
        com.github.owlcs.ontapi.tmp.TmpTurtleInvestigation.main(TmpTurtleInvestigation.java:25)



	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:236)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1105)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1055)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1005)
sszuev added a commit to owlcs/ont-api that referenced this issue Aug 7, 2024
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

1 participant