marklogic / marklogic-jena

Adapter for using MarkLogic with the Jena RDF Framework
Other
5 stars 11 forks source link

Unrecognized binding type in MarkLogicDatasetGraph #79

Open AlexTo opened 5 years ago

AlexTo commented 5 years ago

Found a bug in function bindObject() in MarkLogicDatasetGraph.java while importing Mappingbased Literals downloaded from https://wiki.dbpedia.org/downloads-2016-10

DBPedia uses a number of non-standard data types for e.g. http://dbpedia.org/datatype/usDollar and RDFTypes.valueOf(fragment.toUpperCase()) will return null so I added a catch for NullPointerException and assign it to RDFTypes.STRING

 try {
  String xsdType = objectNode.getLiteralDatatypeURI();
  String fragment = new URI(xsdType).getFragment();
  bindings.bind(variableName,
                            objectNode.getLiteralLexicalForm(),
                            RDFTypes.valueOf(fragment.toUpperCase()));
  } catch (URISyntaxException e) {
     throw new MarkLogicJenaException(
                           "Unrecognized binding type.  Use XSD only.", e);
  } catch (NullPointerException e) {
        log.error("Unrecognized binding type: " + objectNode.getLiteralDatatypeURI());
        bindings.bind(variableName, objectNode.getLiteralLexicalForm(),
                            RDFTypes.STRING); // <-- added this catch block
 }