class UrlHelper {

    public static void makeAbsoluteUrls(Document document) {
        String documentUrl = document.getDocumentURI();
        String baseUrl = getBaseUrl(document);

        for (String attribute : LINK_ATTRIBUTES) {
            String xpath = "//*[@" + attribute + "]";
            List<Node> nodes = XPathHelper.getXhtmlNodes(document, xpath);
            for (Node node : nodes) {
                Node attributeNode = node.getAttributes().getNamedItem(attribute);
                String value = attributeNode.getNodeValue();
                String fullValue = makeFullUrl(documentUrl, baseUrl, value);
                if (!fullValue.equals(value)) {
                    LOGGER.trace("{} -> {}", value, fullValue);
                    attributeNode.setNodeValue(fullValue);
                }
            }
        }
    }

    private  UrlHelper();

}