protected Element loadDocument ( String ctx_str , String loc_str , EntityResolver resolver ) { try { final URL ctx = new URL ( ctx_str ) ; final URL doc = new URL ( ctx , loc_str ) ; // Use an EntityResolver if provided... final SAXReader rdr = new SAXReader ( ) ; if ( resolver != null ) { rdr . setEntityResolver ( resolver ) ; } // Read by passing a URL -- don't manage the URLConnection yourself... final Element rslt = rdr . read ( doc ) . getRootElement ( ) ; rslt . normalize ( ) ; return rslt ; } catch ( Throwable t ) { String msg = "Unable to read the specified document:" + "\n\tCONTEXT=" + ctx_str + "\n\tLOCATION=" + loc_str ; throw new RuntimeException ( msg , t ) ; } }
Loads a DOM4J document from the specified contact and location and returns the root Element