public MetadataParser(final String uri, final HashMap<String, String> namespaces) throws ApplicationException {
    if (uri == null || uri.isEmpty()) {
      throw new IllegalArgumentException(
          "The value for the parameter uri in the constructor of ModsMetadataParser mustn't be empty.");
    }
    this.uri = uri;
    
    // define the Saxon processor
    Processor processor = new Processor(false);
    xPathCompiler = processor.newXPathCompiler();
    // declare each namespace
    for (String namespace : namespaces.keySet()) {
      xPathCompiler.declareNamespace(namespace, namespaces.get(namespace));
    }
    DocumentBuilder builder = processor.newDocumentBuilder();
    try {
      contextItem = builder.build(new File(uri));
    } catch (SaxonApiException e) {
      throw new ApplicationException("Error while trying to access file using Saxon: "+uri);      
    }
  }