href = XMLParser.absolutize(systemId, href);
href = XMLParser.absolutize(base, href);
  boolean includeResource(String href, String parse, String xpointer,                          String encoding, String accept,                          String acceptLanguage)  {    included = false;    try      {        if (xpointer != null)          throw new XMLStreamException("xpointer attribute not yet supported");        if (href == null || "".equals(href))          href = systemId;        else          href = XMLParser.absolutize(systemId, href);        if (parse == null || "xml".equals(parse))          {            seen.clear();            result = null;            snapshotIndex = 0;            walker = null;            current = null;            backtracking = false;                        URLConnection connection = getURLConnection(href, accept,                                                        acceptLanguage);            InputStream in = connection.getInputStream();            Document doc = getDocumentBuilder().parse(in, href);            DocumentTraversal dt = getDocumentTraversal(doc);            if (xpointer == null)              {                result = null;                Node item = doc.getDocumentElement();                walker = dt.createTreeWalker(item, SHOW_FLAGS, null,                                             expandERefs);              }            else              {                result = null;                snapshotIndex = 0;                walker = null;                // shorthand or scheme-based?                int lpi = xpointer.indexOf('(');                int rpi = xpointer.indexOf(')', lpi);                if (lpi != -1 && rpi != -1)                  {                    String scheme = xpointer.substring(0, lpi);                    if ("element".equals(scheme))                      {                        // element() scheme                        String elementSchemeData =                          xpointer.substring(lpi + 1, rpi);                        Node item = doc;                        int si = elementSchemeData.indexOf('/');                        if (si == -1)                          {                            if (elementSchemeData.length() > 0)                              item = doc.getElementById(elementSchemeData);                          }                        else                          {                            if (si > 0)                              {                                String context =                                  elementSchemeData.substring(0, si);                                item = doc.getElementById(context);                                elementSchemeData =                                  elementSchemeData.substring(si + 1);                              }                            StringTokenizer st =                              new StringTokenizer(elementSchemeData, "/");                            while (st.hasMoreTokens() && item != null)                              {                                int n = Integer.parseInt(st.nextToken());                                Node ctx = item.getFirstChild();                                int count = 1;                                while (ctx != null && count++ < n)                                  ctx = ctx.getNextSibling();                                item = ctx;                              }                          }                        walker = dt.createTreeWalker(item, SHOW_FLAGS, null,                                                     expandERefs);                        included = true;                      }                    else if ("xpointer".equals(scheme))                      {                        xpointer = xpointer.substring(lpi + 1, rpi);                        XPathEvaluator eval = getXPathEvaluator(doc);                        XPathNSResolver resolver = eval.createNSResolver(doc);                        result =                          (XPathResult) eval.evaluate(xpointer, doc,                                                      resolver,                                                      XPathResult.ANY_TYPE,                                                      null);                        // TODO xpointer() scheme functions                        included = true;                      }                    else                      {                        String msg = "Unknown XPointer scheme: " + scheme;                        throw new XMLStreamException(msg);                      }                  }                else                  {                    Node item = doc.getElementById(xpointer);                    walker = dt.createTreeWalker(item, SHOW_FLAGS, null,                                                 expandERefs);                    included = true;                  }              }          }        else if ("text".equals(parse))          {            URLConnection connection = getURLConnection(href, accept,                                                        acceptLanguage);            InputStream in = connection.getInputStream();            if (encoding == null)              {                encoding = connection.getContentEncoding();                if (encoding == null)                  {                    String contentType = connection.getContentType();                    if (contentType != null)                      encoding = getParameter(contentType, "charset");                  }              }            if (encoding == null)              includedText = new InputStreamReader(in, "UTF-8");            else              includedText = new InputStreamReader(in, encoding);            included = true;          }        else          throw new XMLStreamException("value of 'parse' attribute must be "+                                       "'xml' or 'text'");        return true;      }    catch (IOException e)      {        return false;      }    catch (XMLStreamException e)      {        return false;      }    catch (SAXException e)      {        return false;      }  }