sszuev commented on issue #2620:
URL: https://github.com/apache/jena/issues/2620#issuecomment-2268267729

   What about this ?
   ```java
   String data = """
           <?xml version="1.0"?>
           <Ontology xmlns="http://www.w3.org/2002/07/owl#";
                xml:base="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#";>
               <Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
               <Prefix name="rdf" 
IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
               <Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
               <Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
               <Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
               <Declaration>
                   <Class IRI="http://x#X"/>
               </Declaration>
           </Ontology>
           """;
   ModelFactory.createDefaultModel()
           .read(new StringReader(data), null, "rdf/xml")
           .setNsPrefixes(PrefixMapping.Standard).write(System.out, "ttl");
   ```
   output
   ```
   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#>
   
   [ rdf:type         owl:Ontology;
     owl:Declaration  [ rdf:type  owl:Class ];
     owl:Prefix       ""
   ] .
   ```
   To create such a document, OWLAPI or owlcs/ONTAPI can be used:
   ```java
   OWLOntologyManager m = OntManagers.createOWLAPIImplManager();
   OWLOntology ont = m.createOntology();
   
ont.add(m.getOWLDataFactory().getOWLDeclarationAxiom(m.getOWLDataFactory().getOWLClass(IRI.create("http://x#X";))));
   ont.saveOntology(new OWLXMLDocumentFormat(), System.out);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to