예제 #1
0
 /**
  * Construct a resource directive from source.
  *
  * @param uri the source uri
  * @return the resource directive
  * @exception IOException if an IO exception occurs
  */
 public ResourceDirective buildResource(URI uri) throws IOException {
   try {
     final Document document = DOCUMENT_BUILDER.parse(uri);
     Element root = document.getDocumentElement();
     return buildResourceDirectiveFromElement(null, root, null);
   } catch (Exception e) {
     final String error =
         "Unexpected error while attempting to load module." + "URI: '" + uri + "'";
     IOException ioe = new IOException(error);
     ioe.initCause(e);
     throw ioe;
   }
 }
예제 #2
0
 /**
  * Resolve the root DOM element of the supplied file.
  *
  * @param source the source XML file
  * @return the root element
  * @exception IOException if an io error occurs
  */
 private Element getRootElement(File source) throws IOException {
   File file = source.getCanonicalFile();
   final Document document = DOCUMENT_BUILDER.parse(file.toURI());
   return document.getDocumentElement();
 }