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

Explicit prefix ignored during serialization #529

Closed
danielepantaleone opened this issue May 30, 2016 · 1 comment
Closed

Explicit prefix ignored during serialization #529

danielepantaleone opened this issue May 30, 2016 · 1 comment

Comments

@danielepantaleone
Copy link

danielepantaleone commented May 30, 2016

I'm experiencing another bug which is probably caused by some regression introduced in #522. Whenever I serialize my OWL ontology using a prefix based syntax (i.e: Functional Style Syntax, Manchester OWL syntax, etc.) The prefixes I specify for my ontology entities are replaced by the IRI. Example:

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat;
import org.semanticweb.owlapi.io.OWLOntologyDocumentTarget;
import org.semanticweb.owlapi.io.StringDocumentTarget;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.util.DefaultPrefixManager;

public class Main {

    public static void main (String args[]) throws OWLOntologyCreationException, OWLOntologyStorageException {
        OWLOntologyManager man = OWLManager.createOWLOntologyManager();
        OWLOntology ontology = man.createOntology(IRI.create("http://www.dis.uniroma1.it/pizza"));
        OWLDataFactory dataFactory = man.getOWLDataFactory();
        PrefixManager pm = new DefaultPrefixManager();
        pm.setPrefix("pizza", "http://www.dis.uniroma1.it/pizza");
        OWLClass pizza = dataFactory.getOWLClass("pizza:PizzaBase", pm);
        OWLDeclarationAxiom declarationAxiom = dataFactory.getOWLDeclarationAxiom(pizza);
        man.addAxiom(ontology, declarationAxiom);
        FunctionalSyntaxDocumentFormat ontoFormat = new FunctionalSyntaxDocumentFormat();
        ontoFormat.copyPrefixesFrom(pm);
        man.setOntologyFormat(ontology, ontoFormat);
        OWLOntologyDocumentTarget stream = new StringDocumentTarget();
        man.saveOntology(ontology, stream);
        System.out.println(stream.toString());
    }
}

produces the following:

Prefix(:=<http://www.dis.uniroma1.it/pizza#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Prefix(pizza:=<http://www.dis.uniroma1.it/pizza>)

Ontology(<http://www.dis.uniroma1.it/pizza>

Declaration(Class(<http://www.dis.uniroma1.it/pizzaPizzaBase>))
)

Here you can see Declaration(Class(<http://www.dis.uniroma1.it/pizzaPizzaBase>)) while I was expecting: Declaration(Class(<pizza:PizzaBase>)). I'm using OWLapi version 4.

@ignazio1977
Copy link
Contributor

It's unrelated to the previous issue: this depends on the IRI for the pizza class being http://www.dis.uniroma1.it/pizzaPizzaBase. The default namespace for this IRI is http://www.dis.uniroma1.it/, and that's what's used to find suitable prefixes. This is reductive, as when the default namespace is not replaced, then it's legitimate to try and use any suitable replacement.

@ignazio1977 ignazio1977 changed the title Explicit prefix is overridden by IRI during OWL serialization Explicit prefix ignored during serialization Sep 10, 2016
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