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

Saving fails for ontologies containing XMLLiteral #495

Closed
tudorache opened this issue Mar 3, 2016 · 12 comments
Closed

Saving fails for ontologies containing XMLLiteral #495

tudorache opened this issue Mar 3, 2016 · 12 comments
Labels

Comments

@tudorache
Copy link

OWl API 4.1.3 loads the attached file (see below) just fine. The file contains an XML Literal as the value of an annotation property:

    <owl:Class rdf:about="http://ttania.owl/OWLClass_ce266563_6ce0_4958_b061_a1d2a62b7e86">
        <rdfs:label xml:lang="en">ClassA</rdfs:label>        
        <ncicp:annotProp rdf:parseType="Literal"><ncicp:ComplexTerm xmlns:ncicp="http://ncicb.nci.nih.gov/xml/owl/EVS/ComplexProperties.xsd#"><ncicp:term-name>Role_Has_Parent</ncicp:term-name><ncicp:term-group>PT</ncicp:term-group><ncicp:term-source>NCI</ncicp:term-source></ncicp:ComplexTerm></ncicp:annotProp>
    </owl:Class>

However, when trying to save the ontology, OWL API throws the exception shown below. (The exception is generated by Protege 5.0.0-b23, but it can also be reproduced just with the OWL API)

OWL API 3.5.1 loads and saves this file with no error.

File that shows the behavior: textXmlLiteral_5.owl.zip

If the syntax is valid (I believe it is), then the OWL API should load and save the file successfully. If the syntax is invalid, I would expect to see an error at load time.

Related to #412 and #439.

Exception when trying to save the file:

An error was thrown: org.semanticweb.owlapi.model.OWLOntologyStorageException: java.io.IOException: XML literal is not self contained: "<ncicp:ComplexTerm><ncicp:term-name>Role_Has_Parent</ncicp:term-name><ncicp:term-group>PT</ncicp:term-group><ncicp:term-source>NCI</ncicp:term-source></ncicp:ComplexTerm>" 
org.semanticweb.owlapi.model.OWLOntologyStorageException: org.semanticweb.owlapi.model.OWLOntologyStorageException: java.io.IOException: XML literal is not self contained: "<ncicp:ComplexTerm><ncicp:term-name>Role_Has_Parent</ncicp:term-name><ncicp:term-group>PT</ncicp:term-group><ncicp:term-source>NCI</ncicp:term-source></ncicp:ComplexTerm>"
    at org.protege.editor.owl.model.OWLModelManagerImpl.save(OWLModelManagerImpl.java:528) ~[na:na]
    at org.protege.editor.owl.OWLEditorKit.handleSaveAs(OWLEditorKit.java:308) ~[na:na]
    at org.protege.editor.owl.OWLEditorKit.handleSaveAs(OWLEditorKit.java:271) ~[na:na]
    at org.protege.editor.core.ProtegeManager.saveEditorKitAs(ProtegeManager.java:318) ~[na:na]
    at org.protege.editor.core.ui.action.SaveAsAction.actionPerformed(SaveAsAction.java:24) ~[na:na]
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) [na:1.8.0_40]
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346) [na:1.8.0_40]
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) [na:1.8.0_40]
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) [na:1.8.0_40]
    at javax.swing.AbstractButton.doClick(AbstractButton.java:376) [na:1.8.0_40]
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833) [na:1.8.0_40]
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877) [na:1.8.0_40]
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289) [na:1.8.0_40]
    at java.awt.Component.processMouseEvent(Component.java:6525) [na:1.8.0_40]
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) [na:1.8.0_40]
    at java.awt.Component.processEvent(Component.java:6290) [na:1.8.0_40]
    at java.awt.Container.processEvent(Container.java:2234) [na:1.8.0_40]
    at java.awt.Component.dispatchEventImpl(Component.java:4881) [na:1.8.0_40]
    at java.awt.Container.dispatchEventImpl(Container.java:2292) [na:1.8.0_40]
    at java.awt.Component.dispatchEvent(Component.java:4703) [na:1.8.0_40]
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898) [na:1.8.0_40]
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533) [na:1.8.0_40]
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462) [na:1.8.0_40]
    at java.awt.Container.dispatchEventImpl(Container.java:2278) [na:1.8.0_40]
    at java.awt.Window.dispatchEventImpl(Window.java:2750) [na:1.8.0_40]
    at java.awt.Component.dispatchEvent(Component.java:4703) [na:1.8.0_40]
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751) [na:1.8.0_40]
    at java.awt.EventQueue.access$500(EventQueue.java:97) [na:1.8.0_40]
    at java.awt.EventQueue$3.run(EventQueue.java:702) [na:1.8.0_40]
    at java.awt.EventQueue$3.run(EventQueue.java:696) [na:1.8.0_40]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_40]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) [na:1.8.0_40]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86) [na:1.8.0_40]
    at java.awt.EventQueue$4.run(EventQueue.java:724) [na:1.8.0_40]
    at java.awt.EventQueue$4.run(EventQueue.java:722) [na:1.8.0_40]
    at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_40]
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) [na:1.8.0_40]
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:721) [na:1.8.0_40]
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) [na:1.8.0_40]
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) [na:1.8.0_40]
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) [na:1.8.0_40]
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [na:1.8.0_40]
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) [na:1.8.0_40]
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) [na:1.8.0_40]
Caused by: org.semanticweb.owlapi.model.OWLOntologyStorageException: java.io.IOException: XML literal is not self contained: "<ncicp:ComplexTerm><ncicp:term-name>Role_Has_Parent</ncicp:term-name><ncicp:term-group>PT</ncicp:term-group><ncicp:term-source>NCI</ncicp:term-source></ncicp:ComplexTerm>"
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLStorer.storeOntology(RDFXMLStorer.java:61) ~[na:na]
    at org.semanticweb.owlapi.util.AbstractOWLStorer.store(AbstractOWLStorer.java:99) ~[na:na]
    at org.semanticweb.owlapi.util.AbstractOWLStorer.storeOntology(AbstractOWLStorer.java:64) ~[na:na]
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.saveOntology(OWLOntologyManagerImpl.java:1217) ~[na:na]
    at org.protege.editor.owl.model.OWLModelManagerImpl.save(OWLModelManagerImpl.java:512) ~[na:na]
    ... 43 common frames omitted
Caused by: java.io.IOException: XML literal is not self contained: "<ncicp:ComplexTerm><ncicp:term-name>Role_Has_Parent</ncicp:term-name><ncicp:term-group>PT</ncicp:term-group><ncicp:term-source>NCI</ncicp:term-source></ncicp:ComplexTerm>"
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.checkProperXMLLiteral(XMLWriterImpl.java:446) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.writeTextContent(XMLWriterImpl.java:433) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.writeElementStart(XMLWriterImpl.java:344) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.writeElementEnd(XMLWriterImpl.java:389) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl.writeEndElement(XMLWriterImpl.java:169) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLWriter.writeEndElement(RDFXMLWriter.java:116) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLRenderer.render(RDFXMLRenderer.java:247) ~[na:na]
    at org.semanticweb.owlapi.rdf.RDFRendererBase.renderEntity(RDFRendererBase.java:274) ~[na:na]
    at org.semanticweb.owlapi.rdf.RDFRendererBase.renderEntities(RDFRendererBase.java:266) ~[na:na]
    at org.semanticweb.owlapi.rdf.RDFRendererBase.renderInOntologySignatureEntities(RDFRendererBase.java:235) ~[na:na]
    at org.semanticweb.owlapi.rdf.RDFRendererBase.renderOntologyComponents(RDFRendererBase.java:217) ~[na:na]
    at org.semanticweb.owlapi.rdf.RDFRendererBase.render(RDFRendererBase.java:212) ~[na:na]
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLStorer.storeOntology(RDFXMLStorer.java:59) ~[na:na]
    ... 47 common frames omitted
Caused by: org.xml.sax.SAXParseException: The prefix "ncicp" for element "ncicp:ComplexTerm" is not bound.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:289) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:605) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3138) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:880) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649) ~[na:1.8.0_40]
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:333) ~[na:1.8.0_40]
    at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.checkProperXMLLiteral(XMLWriterImpl.java:443) ~[na:na]
    ... 59 common frames omitted

@ignazio1977 ignazio1977 added the bug label Mar 3, 2016
@ignazio1977
Copy link
Contributor

xmlns:ncicp="http://ncicb.nci.nih.gov/xml/owl/EVS/ComplexProperties.xsd#" is essential for this literal to be well formed, but it appears to have been lost when the literal reaches saving. That would cause the error.

@tudorache
Copy link
Author

Yes, that makes sense. It is easy to reproduce just by opening the file with the OWL API and saving it. I added some test case that we were using.

File sourceFile = new File("test.owl");
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntology(IRI.create(sourceFile));

File targetFile = new File("test_save.owl");
manager.saveOntology(ontology, IRI.create(targetFile));

@sesuncedu
Copy link
Contributor

sesuncedu commented Mar 3, 2016 via email

@sesuncedu
Copy link
Contributor

sesuncedu commented Mar 3, 2016 via email

@sesuncedu
Copy link
Contributor

sesuncedu commented Mar 3, 2016 via email

@ignazio1977
Copy link
Contributor

I think the name space declaration must be preserved.

Indeed. The XML literal must be a self contained XML fragment, i.e., not rely on the surrounding RDF/XML to provide anything

It is possible that any name spaces used in the literal may need to be added,

Probably not - the idea is that the literal can verbatim be moved about or to other ontologies. That's where the requirement to be self contained comes from, far as I understand it.
(All of which could have been solved elegantly by imposing the contents be escaped, but that's just me ranting. Pay no attention.)

@sesuncedu
Copy link
Contributor

I think that you ought to be right, but I'm not yet sure about whether non
embedded namespace declarations need to be inserted unless they are
declared to be undeclared as xml serialization parameters...

However preserving the declarations in the current example is definitely
permitted as it closely matches the example (09) in the rdf xml syntax
document.
On Mar 3, 2016 4:36 PM, "Ignazio Palmisano" [email protected]
wrote:

I think the name space declaration must be preserved.

Indeed. The XML literal must be a self contained XML fragment, i.e., not
rely on the surrounding RDF/XML to provide anything

It is possible that any name spaces used in the literal may need to be
added,

Probably not - the idea is that the literal can verbatim be moved about or
to other ontologies. That's where the requirement to be self contained
comes from, far as I understand it.
(All of which could have been solved elegantly by imposing the contents be
escaped, but that's just me ranting. Pay no attention.)


Reply to this email directly or view it on GitHub
#495 (comment).

@ignazio1977
Copy link
Contributor

Example 9 is not self contained either - the a appears on the wrong tag. :-)

@jvendetti
Copy link

Hi @ignazio1977. I'm wondering what your timeline is for making this fix part of a release in Maven Central? BioPortal is using version 4.1.0 of the owlapi-distribution, and we're unable to make the latest version of the NCI Thesaurus available due to this OWLOntologyStorageException on save. I'd be interested to try upgrading to whichever release number contains this fix. Thanks!

org.semanticweb.owlapi.model.OWLOntologyStorageException: java.io.IOException: XML literal is not self contained: "<ncicp:ComplexTerm><ncicp:term-name>Disease_Has_Associated_Anatomic_Site</ncicp:term-name><ncicp:term-group>PT</ncicp:term-group><ncicp:term-source>NCI</ncicp:term-source></ncicp:ComplexTerm>"
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLStorer.storeOntology(RDFXMLStorer.java:61)
        at org.semanticweb.owlapi.util.AbstractOWLStorer.store(AbstractOWLStorer.java:99)
        at org.semanticweb.owlapi.util.AbstractOWLStorer.storeOntology(AbstractOWLStorer.java:64)
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.saveOntology(OWLOntologyManagerImpl.java:1217)
        at org.stanford.ncbo.oapiwrapper.OntologyParser.serializeOntology(OntologyParser.java:673)
        at org.stanford.ncbo.oapiwrapper.OntologyParser.internalParse(OntologyParser.java:656)
        at org.stanford.ncbo.oapiwrapper.OntologyParser.parse(OntologyParser.java:624)
        at org.stanford.ncbo.oapiwrapper.OntologyParserCommand.main(OntologyParserCommand.java:55)
Caused by: java.io.IOException: XML literal is not self contained: "<ncicp:ComplexTerm><ncicp:term-name>Disease_Has_Associated_Anatomic_Site</ncicp:term-name><ncicp:term-group>PT</ncicp:term-group><ncicp:term-source>NCI</ncicp:term-source></ncicp:ComplexTerm>"
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.checkProperXMLLiteral(XMLWriterImpl.java:446)
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.writeTextContent(XMLWriterImpl.java:433)
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.writeElementStart(XMLWriterImpl.java:344)
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.writeElementEnd(XMLWriterImpl.java:389)
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl.writeEndElement(XMLWriterImpl.java:169)
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLWriter.writeEndElement(RDFXMLWriter.java:116)
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLRenderer.render(RDFXMLRenderer.java:251)
        at org.semanticweb.owlapi.rdf.RDFRendererBase.renderEntity(RDFRendererBase.java:267)
        at org.semanticweb.owlapi.rdf.RDFRendererBase.renderEntities(RDFRendererBase.java:259)
        at org.semanticweb.owlapi.rdf.RDFRendererBase.renderInOntologySignatureEntities(RDFRendererBase.java:224)
        at org.semanticweb.owlapi.rdf.RDFRendererBase.renderOntologyComponents(RDFRendererBase.java:210)
        at org.semanticweb.owlapi.rdf.RDFRendererBase.render(RDFRendererBase.java:205)
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.RDFXMLStorer.storeOntology(RDFXMLStorer.java:59)
        ... 7 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 20; The prefix "ncicp" for element "ncicp:ComplexTerm" is not bound.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:289)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:605)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3138)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:880)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:332)
        at org.semanticweb.owlapi.rdf.rdfxml.renderer.XMLWriterImpl$XMLElement.checkProperXMLLiteral(XMLWriterImpl.java:443)
        ... 19 more

@ignazio1977
Copy link
Contributor

There's no timeline planned but I don't see obstacles to a patch release within days - possibly tomorrow.

@jvendetti
Copy link

Great! Thanks so much!

@ignazio1977
Copy link
Contributor

4.2.1 has been released

jvendetti added a commit to ncbo/owlapi_wrapper that referenced this issue Mar 7, 2016
Should resolve NCIT save exceptions per
owlcs/owlapi#495.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants