isl / x3ml

X3ML Engine supports the data transformation which is part of the data provisioning and aggregation process.
Apache License 2.0
20 stars 7 forks source link

Strange error messages are thrown when namespace information are empty #120

Closed ymark closed 6 years ago

ymark commented 6 years ago

When namespace information are empty (i.e. prefix and uri ) then some strange error messages occur. This happens if namespaces are declared in the namespace block, as well as if they are declared in the info block. See below some indicative examples.

Empty namespace declared in the namespace block

<namespaces>
    <namespace prefix="" uri="#"/>
</namespaces>

Empty namespace declared in the info block

<target_info>
    <target_schema schema_file="schema.rdfs" type="rdfs" version="1.0">schema</target_schema>
    <namespaces>
        <namespace prefix="" uri=""/>
    </namespaces>
</target_info>

In both case the error message is:

Exception in thread "main" com.hp.hpl.jena.shared.BadURIException: Only well-formed absolute URIrefs can be included in RDF/XML output: <> Code: 57/REQUIRED_COMPONENT_MISSING in SCHEME: A component that is required by the scheme is missing.
    at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.checkURI(BaseXMLWriter.java:836)
    at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.xmlnsDecl(BaseXMLWriter.java:351)
    at com.hp.hpl.jena.xmloutput.impl.Unparser.printNameSpaceDefn(Unparser.java:1075)
    at com.hp.hpl.jena.xmloutput.impl.Unparser.wRDF(Unparser.java:338)
    at com.hp.hpl.jena.xmloutput.impl.Unparser.write(Unparser.java:247)
    at com.hp.hpl.jena.xmloutput.impl.Abbreviated.writeBody(Abbreviated.java:142)
    at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.writeXMLBody(BaseXMLWriter.java:503)
    at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:475)
    at com.hp.hpl.jena.xmloutput.impl.Abbreviated.write(Abbreviated.java:127)
    at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:462)
    at com.hp.hpl.jena.rdf.model.impl.ModelCom.write(ModelCom.java:345)
    at eu.delving.x3ml.engine.ModelOutput.writeXML(ModelOutput.java:125)
    at gr.forth.ics.isl.example.Example.main(Example.java:72)
ymark commented 6 years ago

Added extra checks that validate the prefix and the URI of a namespace when they are added in the XPathContext (the structure that stores the namespaces and the actual URIs).

The validation is carried out in terms of empty values for the prefix and the URI. To this end the following ERROR messages are shown:

When the URI of the namespace is empty:

Invalid namespace declaration: the URI of a namespace cannot be empty [Prefix: "err", URI: (empty)]

When the prefix of the namespace is empty:

Invalid namespace declaration: the prefix of a namespace cannot be empty [Prefix: (empty), URI: "http://localhost/"]

When both the prefix and the URI of the namespace are empty:

Invalid namespace declaration: the prefix of a namespace cannot be empty [Prefix: (empty), URI: (empty)]

In addition, the execution of the transformation stops, because otherwise the error will be thrown from Jena (i.e. for non well-formed URIs).

The fix will appear in version 1.8.5