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

How to force OWL-API to use shortened IRIs in RDF/XML? #1107

Open
trojczak opened this issue Jun 30, 2023 · 1 comment
Open

How to force OWL-API to use shortened IRIs in RDF/XML? #1107

trojczak opened this issue Jun 30, 2023 · 1 comment

Comments

@trojczak
Copy link

Hi!

I have the following simple code:

OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
OWLDataFactory dataFactory = ontologyManager.getOWLDataFactory();
OWLOntology ontology = ontologyManager.createOntology(IRI.create(PREFIX));

OWLClass owlClass1 = dataFactory.getOWLClass(IRI.create(PREFIX + "C1"));
OWLClass owlClass2 = dataFactory.getOWLClass(IRI.create(PREFIX2 + "C2"));

ontology.addAxiom(dataFactory.getOWLDeclarationAxiom(owlClass1));
ontology.addAxiom(dataFactory.getOWLDeclarationAxiom(owlClass2));

RDFXMLDocumentFormat format = new RDFXMLDocumentFormat();
format.setPrefix("o2:", PREFIX2);
ontologyManager.saveOntology(ontology, format, IRI.create("file:/some/path"));

The saved ontology looks like this (I've removed comments):

<?xml version="1.0"?>
<rdf:RDF xmlns="http://example.com/ontology1/"
     xml:base="http://example.com/ontology1/"
     xmlns:o2="http://example.com/ontology2/"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://example.com/ontology1/"/>

    <owl:Class rdf:about="http://example.com/ontology1/C1"/>

    <owl:Class rdf:about="http://example.com/ontology2/C2"/>
</rdf:RDF>

My goal here is to force OWL-API to use shortened IRIs inside the rdf:about property. I.e. to have something like this:

<owl:Class rdf:about="&o2;C2"/>
@ignazio1977 ignazio1977 changed the title How to force OWL-API to use DTDs in RDF/XML? How to force OWL-API to use shortened IRIs in RDF/XML? Jul 13, 2023
@ignazio1977
Copy link
Contributor

format.setPrefix("o2:", PREFIX2);

The semicolon shouldn't be there in the prefix name, try

format.setPrefix("o2", PREFIX2);

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