Package client.net.sf.saxon.ce.tree.util

Examples of client.net.sf.saxon.ce.tree.util.URI


        StringCollator stringCollator;
        if (collation != null) {
            stringCollator = collation;
        } else if (collationName != null) {
            String cname = collationName.evaluateAsString(context).toString();
            URI collationURI;
            try {
                collationURI = new URI(cname, true);
                if (!collationURI.isAbsolute()) {
                    if (baseURI == null) {
                        throw new XPathException("Collation URI is relative, and base URI is unknown");
                    } else {
                        URI base = new URI(baseURI);
                        collationURI = base.resolve(collationURI.toString());
                    }
                }
            } catch (URI.URISyntaxException err) {
                throw new XPathException("Collation name " + cname + " is not a valid URI: " + err);
            }
View Full Code Here


            JavaScriptObject sourceDoc = null;
            String absSourceURI = null;
            if (sourceURI != null && sourceURI.length() != 0) {
              String pageHref = Window.Location.getHref();
                absSourceURI = (new URI(pageHref).resolve(sourceURI)).toString();
                if (pageHref.equals(absSourceURI)) {
                  throw new XPathException("Cannot load XML with same URI as the host page");
                }

                sourceDoc = SaxonceApi.createAsyncDoc(absSourceURI); // config.buildDocument(absSourceURI);

            } else if (initialTemplate == null) {
              throw new XPathException("No data-source attribute or data-initial-template value found - one is required");
            }

            String absStyleURI = (new URI(Window.Location.getHref()).resolve(styleURI)).toString();
            DocumentInfo styleDoc;
            try {
                styleDoc = config.buildDocument(absStyleURI);
            } catch (XPathException e) {
              String reportURI = (absSourceURI != null)? absSourceURI : styleURI;
View Full Code Here

            return true;
        }

        // Allow a string if the java.net.URI class accepts it
        try {
            new URI(sv);
            return true;
        } catch (URI.URISyntaxException e) {
            // keep trying
            // Note: it's expensive to throw exceptions on a success path, so we keep a cache.
        }

        // Allow a string if it can be escaped into a form that java.net.URI accepts
        sv = EscapeURI.iriToUri(sv).toString();
        try {
            new URI(sv);
            return true;
        } catch (URI.URISyntaxException e) {
            return false;
        }
    }
View Full Code Here

  // API
  public static JavaScriptObject requestXML(String URI) throws Exception {

    try {
      String pageHref = Window.Location.getHref();
      String absSourceURI = (new URI(pageHref).resolve(URI)).toString();
      return createAsyncDoc(absSourceURI);
    } catch (Exception e) {
      // re-throw exception back to calling JavaScript
      throw (e);
    }
View Full Code Here

        }
        return conversionContext;
    }
   
    public static URI getLocation() {
      URI location = null;
      try {
        location = new URI(Window.Location.getHref());
      } catch(Exception err) {}
      return location;
    }
View Full Code Here

                return null;
            }
        }

        try {
            URI absoluteURI = new URI(base, true);
            if (!absoluteURI.isAbsolute()) {
                URI relativeURI = new URI(relative, true);
                if (relativeURI.isAbsolute()) {
                    return new AnyURIValue(relative);
                }
                dynamicError(msgBase + "in resolve-uri(): Base URI " + Err.wrap(base) + " is not an absolute URI", "FORG0002", context);
                return null;
            }
            URI resolved = makeAbsolute(relative,  base);
            return new AnyURIValue(resolved.toString());
        } catch (URI.URISyntaxException err) {
            dynamicError(msgBase + "Base URI " + Err.wrap(base) + " is invalid: " + err.getMessage(),
                    "FORG0002", context);
            return null;
        }
View Full Code Here

     * @throws java.net.URISyntaxException if either of the strings is not a valid URI or
     * if the resolution fails
     */

    public static URI makeAbsolute(String relativeURI, String base) throws URI.URISyntaxException {
        URI absoluteURI;
        // System.err.println("makeAbsolute " + relativeURI + " against base " + base);
        if (relativeURI == null) {
            absoluteURI = new URI(ResolveURI.escapeSpaces(base), true);
            if (!absoluteURI.isAbsolute()) {
                throw new URI.URISyntaxException(base + ": Relative URI not supplied, so base URI must be absolute");
            } else {
                return absoluteURI;
            }
        }
        relativeURI = ResolveURI.escapeSpaces(relativeURI);
        base = ResolveURI.escapeSpaces(base);
        try {
            if (base==null || base.length() == 0) {
                absoluteURI = new URI(relativeURI, true);
                if (!absoluteURI.isAbsolute()) {
                    String expandedBase = ResolveURI.tryToExpand(base);
                    if (!expandedBase.equals(base)) { // prevent infinite recursion
                        return makeAbsolute(relativeURI, expandedBase);
                    }
                }

            } else {
                URI baseURI;
                try {
                    baseURI = new URI(base);
                } catch (URI.URISyntaxException e) {
                    throw new URI.URISyntaxException(base +  ": Invalid base URI: " + e.getMessage());
                }
                if (baseURI.getFragment() != null) {
                    int hash = base.indexOf('#');
                    if (hash >= 0) {
                        base = base.substring(0, hash);
                    }
                    try {
                        baseURI = new URI(base);
                    } catch (URI.URISyntaxException e) {
                        throw new URI.URISyntaxException(base +  ": Invalid base URI: " + e.getMessage());
                    }
                }
                try {
                    new URI(relativeURI, true);   // for validation only
                } catch (URI.URISyntaxException e) {
                    throw new URI.URISyntaxException(base + ": Invalid relative URI: " + e.getMessage());
                }
                absoluteURI = (relativeURI.length() == 0 ? baseURI : baseURI.resolve(relativeURI));
            }
        } catch (IllegalArgumentException err0) {
            // can be thrown by resolve() when given a bad URI
            throw new URI.URISyntaxException(relativeURI + ": Cannot resolve URI against base " + Err.wrap(base));
        }
View Full Code Here

    private CharSequence readFile(String href, String baseURI, String encoding, XPathContext context)
            throws XPathException {

        // Use the URI machinery to validate and resolve the URIs

        URI absoluteURI = getAbsoluteURI(href, baseURI);
        try {
            return XMLDOM.makeHTTPRequest(absoluteURI.toString());
        } catch (Exception e) {
            throw new XPathException(e);
        }

    }
View Full Code Here

        }

    }

    private URI getAbsoluteURI(String href, String baseURI) throws XPathException {
        URI absoluteURI;
        try {
            absoluteURI = ResolveURI.makeAbsolute(href, baseURI);
        } catch (URI.URISyntaxException err) {
            XPathException e = new XPathException(err.getMessage());
            e.setErrorCode("XTDE1170");
            throw e;
        }

        if (absoluteURI.getFragment() != null) {
            XPathException e = new XPathException("URI for unparsed-text() must not contain a fragment identifier");
            e.setErrorCode("XTDE1170");
            throw e;
        }

        // The URL dereferencing classes throw all kinds of strange exceptions if given
        // ill-formed sequences of %hh escape characters. So we do a sanity check that the
        // escaping is well-formed according to UTF-8 rules

        EscapeURI.checkPercentEncoding(absoluteURI.toString());
        return absoluteURI;
    }
View Full Code Here

        // reload it.

        if (obj instanceof DocumentInfo) {
            String systemId = ((DocumentInfo)obj).getSystemId();
            try {
                if (systemId != null && new URI(systemId, true).isAbsolute()) {
                    DocumentPool pool = context.getController().getDocumentPool();
                    if (pool.find(systemId) == null) {
                        pool.add(((DocumentInfo)obj), systemId);
                    }
                }
View Full Code Here

TOP

Related Classes of client.net.sf.saxon.ce.tree.util.URI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.