code: public static URI resolveBase(final URI baseURI, final Stack<URI> stack) throws XIncludeFatalException
      {
          final URI computedUri = XIncProcUtils.computeBase(stack);
          final URI resolvedUri = baseURI.resolve(computedUri);
          if (0 == resolvedUri.compareTo(baseURI))
          {
              throw new XIncludeFatalException("Inclusion loop error");
          }
          return resolvedUri;
      }
docs: Resolve base {@link java.net.URI} against a {@link java.util.Stack} of uris.
  
  @param baseURI the base uRI
  @param stack the stack
  @return the resolved URI
  @throws XIncludeFatalException in case of inclusion loop