List of usage examples for org.w3c.dom.html HTMLBaseElement getHref
public String getHref();
From source file:org.fit.cssbox.scriptbox.dom.Html5DocumentImpl.java
/** * Returns Document base address./*w ww . j ava 2 s. c o m*/ * * @return Document base address. * @see <a href="http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#document-base-url">Document base URL</a> */ public URL getBaseAddress() { HTMLBaseElement baseElement = getBaseElement(); URL baseURL = null; try { baseURL = (baseElement != null) ? new URL(baseElement.getHref()) : null; } catch (MalformedURLException e) { e.printStackTrace(); } /* * 1) If there is no base element that has an href attribute in the Document, * then the document base URL is the Document's fallback base URL */ if (baseURL == null) { return getFallbackBaseAddress(); } /* * TODO?: Implement frozen URL? * http://www.w3.org/html/wg/drafts/html/master/document-metadata.html#frozen-base-url */ /* * 2) Otherwise, the document base URL is the frozen base URL of the first * base element in the Document that has an href attribute, in tree order. */ return baseURL; }