code: private static Document loadDocument(URL location) throws IOException, ParserConfigurationException, SAXException {
  
          InputStream inputStream = null;
  
          if (location != null) {
              URLConnection urlConnection = location.openConnection();
              urlConnection.setUseCaches(false);
              inputStream = urlConnection.getInputStream();
          }
          if (inputStream == null) {
          	if (location == null) {
          		throw new IOException("Failed to obtain InputStream for named location: null");
          	} else {
          		throw new IOException("Failed to obtain InputStream for named location: " + location.toExternalForm());
          	}
          }
  
          InputSource inputSource = new InputSource(inputStream);
  
          List<SAXParseException> errors = new ArrayList<SAXParseException>();
          DocumentBuilder docBuilder = constructDocumentBuilder(errors);
  
          Document document = docBuilder.parse(inputSource);
          if (!errors.isEmpty()) {
          	if (location == null) {
          		throw new IllegalStateException("Invalid File: null", (Throwable) errors.get(0));
          	} else {
          		throw new IllegalStateException("Invalid file: " + location.toExternalForm(), (Throwable) errors.get(0));
          	}
          }
          return document;
      }
docs: Helper method to load a DOM Document from the given configuration URL
  @param location The configuration URL
  @return A W3C DOM Document
  @throws IOException If the configuration cannot be read
  @throws ParserConfigurationException If the DOM Parser cannot be initialised
  @throws SAXException If the configuraiton cannot be parsed