code: private static URL findBaseURI(final Element root) {
          URL baseURI = null;
          final List<Element> linksList = root.getChildren("link", OS_NS);
          if (linksList != null) {
              for (final Element element : linksList) {
                  final Element link = element;
                  if (!root.equals(link.getParent())) {
                      break;
                  }
                  String href = link.getAttribute("href").getValue();
                  if (link.getAttribute("rel", OS_NS) == null || link.getAttribute("rel", OS_NS).getValue().equals("alternate")) {
                      href = resolveURI(null, link, href);
                      try {
                          baseURI = new URL(href);
                          break;
                      } catch (final MalformedURLException e) {
                          System.err.println("Base URI is malformed: " + href);
                      }
                  }
              }
          }
          return baseURI;
      }
docs: Use feed links and/or xml:base attribute to determine baseURI of feed