# HG changeset patch # User Chris Cannam # Date 1412166935 -3600 # Node ID 136d8496a4b82ad106d79f99d3f58d20e0a25efd # Parent 03b1d83fca292743290a6f4256947e95620deeb9 Skip trying RDF parser if we have a filename ending in xml (we don't support RDF-XML and it just confuses the Turtle parser) diff -r 03b1d83fca29 -r 136d8496a4b8 runner/FeatureExtractionManager.cpp --- a/runner/FeatureExtractionManager.cpp Wed Oct 01 08:49:01 2014 +0100 +++ b/runner/FeatureExtractionManager.cpp Wed Oct 01 13:35:35 2014 +0100 @@ -373,25 +373,37 @@ bool FeatureExtractionManager::addFeatureExtractorFromFile (QString transformXmlFile, const vector &writers) { - RDFTransformFactory factory - (QUrl::fromLocalFile(QFileInfo(transformXmlFile).absoluteFilePath()) - .toString()); - ProgressPrinter printer("Parsing transforms RDF file"); - std::vector transforms = factory.getTransforms(&printer); - if (!factory.isOK()) { - cerr << "WARNING: FeatureExtractionManager::addFeatureExtractorFromFile: Failed to parse transforms file: " << factory.getErrorString().toStdString() << endl; - if (factory.isRDF()) { - return false; // no point trying it as XML - } + bool tryRdf = true; + + if (transformXmlFile.endsWith(".xml") || transformXmlFile.endsWith(".XML")) { + // We don't support RDF-XML (and nor does the underlying + // parser library) so skip the RDF parse if the filename + // suggests XML, to avoid puking out a load of errors from + // feeding XML to a Turtle parser + tryRdf = false; } - if (!transforms.empty()) { - bool success = true; - for (int i = 0; i < (int)transforms.size(); ++i) { - if (!addFeatureExtractor(transforms[i], writers)) { - success = false; + + if (tryRdf) { + RDFTransformFactory factory + (QUrl::fromLocalFile(QFileInfo(transformXmlFile).absoluteFilePath()) + .toString()); + ProgressPrinter printer("Parsing transforms RDF file"); + std::vector transforms = factory.getTransforms(&printer); + if (!factory.isOK()) { + cerr << "WARNING: FeatureExtractionManager::addFeatureExtractorFromFile: Failed to parse transforms file: " << factory.getErrorString().toStdString() << endl; + if (factory.isRDF()) { + return false; // no point trying it as XML } } - return success; + if (!transforms.empty()) { + bool success = true; + for (int i = 0; i < (int)transforms.size(); ++i) { + if (!addFeatureExtractor(transforms[i], writers)) { + success = false; + } + } + return success; + } } QFile file(transformXmlFile);