Package org.w3c.dom.ls

Examples of org.w3c.dom.ls.LSInput


         * returned into an <code>InputSource</code>.
         */
        public InputSource resolveEntity(String name, String publicId,
                String baseURI, String systemId) throws SAXException, IOException {
            if (fEntityResolver != null) {
                LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
                if (lsInput != null) {
                    final String pubId = lsInput.getPublicId();
                    final String sysId = lsInput.getSystemId();
                    final String baseSystemId = lsInput.getBaseURI();
                    final Reader charStream = lsInput.getCharacterStream();
                    final InputStream byteStream = lsInput.getByteStream();
                    final String data = lsInput.getStringData();
                    final String encoding = lsInput.getEncoding();

                    /**
                     * An LSParser looks at inputs specified in LSInput in
                     * the following order: characterStream, byteStream,
                     * stringData, systemId, publicId. For consistency
View Full Code Here


      impl = getDOMImpl();
    }

    public LSInput resolveResource(String type, String namespaceURI, String publicId,
        String systemId, String baseURI) {
      LSInput lsInput = impl.createLSInput();
      InputStream is = getClass().getResourceAsStream("/" + systemId);
      if (is == null)
        return null;
      lsInput.setByteStream(is);
      return lsInput;
    }
View Full Code Here

    return parse(s, false);
  }

  public static Document parse(String s, boolean validateIfSchema) {
    DOMImplementationLS impl = getDOMImpl();
    LSInput input = impl.createLSInput();
    input.setStringData(s);
    return parse(input, validateIfSchema);
  }
View Full Code Here

    return parse(input, validateIfSchema);
  }
 
  public static Document parse(InputStream s, boolean validateIfSchema) {
    DOMImplementationLS impl = getDOMImpl();
    LSInput input = impl.createLSInput();
    input.setByteStream(s);
    return parse(input, validateIfSchema);
  }
View Full Code Here

   public static XSModel loadSchema(final Reader xsdReader)
   {
      XSImplementation impl = getXSImplementation();
      XSLoader schemaLoader = impl.createXSLoader(null);

      XSModel model = schemaLoader.load(new LSInput()
      {
         public Reader getCharacterStream()
         {
            return xsdReader;
         }
View Full Code Here

    }

    private LSInput loadLSInput(String ns) {
        String path = ToolConstants.CXF_SCHEMAS_DIR_INJAR + NSFILEMAP.get(ns);
        URL url = getClass().getClassLoader().getResource(path);
        LSInput lsin = new LSInputImpl();
        lsin.setSystemId(url.toString());
        try {
            lsin.setByteStream(url.openStream());
        } catch (IOException e) {
            return null;
        }
        return lsin;
    }
View Full Code Here

        LOG.log(Level.FINE, msg.toString());
        if (NSFILEMAP.containsKey(namespaceURI)) {
            return loadLSInput(namespaceURI);
        }

        LSInput lsin = null;
        String resURL = null;
        String localFile = null;
        if (systemId != null) {
            String schemaLocation = "";
            if (baseURI != null) {
                schemaLocation = baseURI.substring(0, baseURI.lastIndexOf("/") + 1);
            }
            if (systemId.indexOf("http://") < 0) {
                resURL = schemaLocation + systemId;
            } else {
                resURL = systemId;
            }
        } else if (namespaceURI != null) {
            resURL = namespaceURI;
        }

        if (resURL != null && resURL.startsWith("http://")) {
            String filename = NSFILEMAP.get(resURL);
            if (filename != null) {
                localFile = ToolConstants.CXF_SCHEMAS_DIR_INJAR + filename;
            } else {
                URL url;
                URLConnection urlCon = null;
                try {
                    url = new URL(resURL);
                    urlCon = url.openConnection();
                    urlCon.setUseCaches(false);
                    lsin = new LSInputImpl();
                    lsin.setSystemId(resURL);
                    lsin.setByteStream(urlCon.getInputStream());
                    msg = new Message("RESOLVE_FROM_REMOTE", LOG, url);
                    LOG.log(Level.FINE, msg.toString());
                    return lsin;
                } catch (Exception e) {
                    e.printStackTrace();
                    return null;
                }
            }
        } else if (resURL != null && !resURL.startsWith("http:")) {
            localFile = resURL;
        else {
            return null;
        }


        URIResolver resolver;
        try {
            msg = new Message("RESOLVE_FROM_LOCAL", LOG, localFile);
            LOG.log(Level.FINE, msg.toString());

            resolver = new URIResolver(localFile);
            if (resolver.isResolved()) {
                lsin = new LSInputImpl();
                lsin.setSystemId(localFile);
                lsin.setByteStream(resolver.getInputStream());
            }
        } catch (IOException e) {
            return null;
        }
        return lsin;
View Full Code Here

            throw new ServiceRuntimeException(e);
        }
        DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
        DOMImplementationLS ls = (DOMImplementationLS)impl.getFeature("LS", "3.0");
        LSParser parser = ls.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, SCHEMA_NS);
        LSInput input = ls.createLSInput();
        input.setCharacterStream(new StringReader(schema));
        Document document = parser.parse(input);
        XSDefinition definition = factory.createXSDefinition();
        definition.setUnresolved(true);
        definition.setDocument(document);
        definition.setNamespace(ns);
View Full Code Here

        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS domLS = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSParser lsParser = domLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

        LSInput input = domLS.createLSInput();
        input.setStringData(xml);
        Document document = lsParser.parse(input);

        LSSerializer lsSerializer = domLS.createLSSerializer();
        lsSerializer.getDomConfig().setParameter("comments", Boolean.FALSE);
        lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
View Full Code Here

   * @return The {@link Document} parsed from the input.
   */
  public static Document parse(InputStream byteStream) {
    // input
    DOMImplementationLS impl = (DOMImplementationLS) getDOMImplementation();
    LSInput input = impl.createLSInput();
    input.setByteStream(byteStream);

    // parse without comments and whitespace
    LSParser builder = impl.createLSParser(
        DOMImplementationLS.MODE_SYNCHRONOUS, null);
    DOMConfiguration config = builder.getDomConfig();
View Full Code Here

TOP

Related Classes of org.w3c.dom.ls.LSInput

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.